Does making a constructor having multiple arguments explicit
have any (useful) effect?
Example:
class A {
public:
explicit A( in
Here's my five cents to this discussion:
struct Foo {
Foo(int, double) {}
};
struct Bar {
explicit Bar(int, double) {}
};
void foo(const Foo&) {}
void bar(const Bar&) {}
int main(int argc, char * argv[]) {
foo({ 42, 42.42 }); // valid
bar({ 42, 42.42 }); // invalid
return 0;
}
As you can easily see, explicit
prevents from using initializer list alongside with bar
function bacause the constructor of struct Bar
is declared as explicit
.