I recently stumbles across some problem with initializer lists. Consider a program that stores map-like data
struct MyMapLike {
MyMapLike(std::map
Wouldn't something like this give the desired effect (MyMapLike can be constructed in any way that std::map can, but does not implicitly convert to std::map)?
struct MyMapLike : private std::map
{
using map::map;
};
If it absolutely positively has to be a member, maybe use constructor perfect forwarding (I'm not sure about the exact syntax) along the lines of:
struct MyMapLike
{
template
MyMapLike(Initializers... init, decltype(new std::map(...init)) = 0)
: data(...init)
{ }
private:
std::map data;
};