R
Ralf Goertz
Hi,
I'm experimenting with the new initializer list feature and I am
wondering why the following doesn't work:
#include <map>
typedef std::map<int,int> IntMap;
struct foo : public IntMap
{
foo(const IntMap &n):IntMap(n) {}
};
int main()
{
IntMap im={{42,0x815}};
foo works=im;
foo doesnt_work={{42,0x815}};
return 0;
}
When trying to initialize "doesnt_work" the compiler (g++ 4.5.1)
complains
error: could not convert ‘{{42, 2069}}’ to ‘foo’
What makes it impossible for foo to be initialized with a list?
I'm experimenting with the new initializer list feature and I am
wondering why the following doesn't work:
#include <map>
typedef std::map<int,int> IntMap;
struct foo : public IntMap
{
foo(const IntMap &n):IntMap(n) {}
};
int main()
{
IntMap im={{42,0x815}};
foo works=im;
foo doesnt_work={{42,0x815}};
return 0;
}
When trying to initialize "doesnt_work" the compiler (g++ 4.5.1)
complains
error: could not convert ‘{{42, 2069}}’ to ‘foo’
What makes it impossible for foo to be initialized with a list?