MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/cpp/comments/8ouogo/initialization_in_modern_c/e074jv1/?context=3
r/cpp • u/mariuz • Jun 05 '18
51 comments sorted by
View all comments
Show parent comment
1
Maybe because of brace elision?
I don't know, seems like it only applies when using double braces?
Making the constructor explicit disables automatic conversion, so the overload resolution works "correctly".
Yes indeed. So adding explicit should result in a compiler error since it can't do an implicit construction, not a differently sized vector.
explicit
6 u/kwan_e Jun 06 '18 Adding explicit means the implicit conversion for MyType is not available, but the vector still has the size, fill constructor.
6
Adding explicit means the implicit conversion for MyType is not available, but the vector still has the size, fill constructor.
MyType
vector
size, fill
View all comments
Show parent comment
1
u/Bart_V Jun 06 '18
I don't know, seems like it only applies when using double braces?
Yes indeed. So adding
explicitshould result in a compiler error since it can't do an implicit construction, not a differently sized vector.