My text insists there's a signifigant difference, and that it's a design consideration, but I can't get any demonstrable effect, practical or otherwise.
Your text, though you didn't say what it said, is almost certainly correct.
There is a significant difference regardless of the details of the text.
However, `std::initializer_list' isn't all that important; the difference of between implicit and explicit constructors apply almost regardless of the types involved in the constructors parameters as long as the given constructor can be called with only one real parameter.
I've included what is likely to be the most common case which readily yields arguments for and against explicit constructors.
Ultimately, the choice is a simple one: do you want to allow automated construction of a class from an arbitrarily implied value?
Unfortunately, the choice is has far reaching implications. The example actually only suggests one immediate problem. When more sophisticated polymorphisms are at play the problems may be more subtle such as entirely changing the meaning of a program.
However, there is a fairly simple "rule-of-thumb": unless the class in question represents an object intended to closely mimic native types, such as a "big number" class, prefer to use explicit conversions.
Soma
Code:
#include <initializer_list>
#include <iostream>
struct Tester1
{
Tester1(std::initializer_list<int>)
{
}
};
struct Tester2
{
Tester2(std::initializer_list<int>)
{
}
};
struct Tester3
{
explicit Tester3(std::initializer_list<int>)
{
}
};
void Test1(const Tester1 &)
{
}
void Test2(const Tester1 &)
{
}
void Test2(const Tester2 &)
{
}
void Test3(const Tester3 &)
{
}
int main()
{
Test1({1,2,3}); // fine
//Test2({1,2,3}); // ambiguous
Test2(Tester1({1,2,3})); // fine
Test2(Tester2({1,2,3})); // fine
//Test3({1,2,3}); // error no implicit conversion path
Test3(Tester3({1,2,3})); // fine
return(0);
}