Aug 4, 2014

[C++11] empty initializer_list

{} will be matched to Fun(int=1) i.e ,
Fun tmp = {};
Code:
#include <initializer_list>

using namespace std;

struct Fun
{
    Fun(int=1)
    {
    }

    explicit Fun(initializer_list<int>)
    {
    }
};

void fun(const Fun&)
{

}

int main()
{
    fun({});
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.