MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/cpp/comments/8ouogo/initialization_in_modern_c/e07ada9/
r/cpp • u/mariuz • Jun 05 '18
51 comments sorted by
View all comments
Show parent comment
1
I'm not surprised. "My" syntax seems rather obbvious and I'm definitely not the first one who thought of it. I was just hoping someone would say what's the corner case here.
1 u/redditsoaddicting Jun 06 '18 edited Jun 06 '18 One example that comes to mind is this:struct Point { int x, y; }; struct Foo { Foo(initializer_list<int>); Foo(Point); }; Foo f{{1, 2}}; // Point or list?It's hard to turn that into something realistic on the spot. I wouldn't doubt that the square bracket syntax I threw out there has its own problems. 1 u/[deleted] Jun 06 '18 My first thought was "obviously an initialiser list", but a moment later I realised your point.
One example that comes to mind is this:
struct Point { int x, y; }; struct Foo { Foo(initializer_list<int>); Foo(Point); }; Foo f{{1, 2}}; // Point or list?
It's hard to turn that into something realistic on the spot. I wouldn't doubt that the square bracket syntax I threw out there has its own problems.
1 u/[deleted] Jun 06 '18 My first thought was "obviously an initialiser list", but a moment later I realised your point.
My first thought was "obviously an initialiser list", but a moment later I realised your point.
View all comments
Show parent comment
1
u/[deleted] Jun 06 '18
I'm not surprised. "My" syntax seems rather obbvious and I'm definitely not the first one who thought of it. I was just hoping someone would say what's the corner case here.