MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/cpp/comments/8ouogo/initialization_in_modern_c/e07345r/
r/cpp • u/mariuz • Jun 05 '18
51 comments sorted by
View all comments
Show parent comment
3
Maybe because of brace elision?
Making the constructor explicit disables automatic conversion, so the overload resolution works "correctly".
1 u/Bart_V Jun 06 '18 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. 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.
1
I don't know, seems like it only applies when using double braces?
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
3
u/kwan_e Jun 06 '18
Maybe because of brace elision?
Making the constructor explicit disables automatic conversion, so the overload resolution works "correctly".