4 ms·
> char * init_out{out}; Are the curly braces in the initialization some new C++ syntax? I haven't been keeping up with C++ developments in the last decade or s
by avian 4y ago
> char * init_out{out};
Are the curly braces in the initialization some new C++ syntax? I haven't been keeping up with C++ developments in the last decade or so.
Based on the code that follows I would expect
char* init_out = out;
- unwind 4y agoYes, I was going to comment on that both code samples are C++, even though they are not clearly labelled as such. List initialization seems to be the recommended syntax to use nowadays in C++ [1]. I'm a fan of the type of optimization and exploration that Lemire often publishes, it's really cool and impressive. I just have a pet peeve about people lumping together C and C++ as if they're interchangable when they are (more clearly than ever, and growing further apart) not. [1]: https://en.cppreference.com/w/cpp/language/list_initialization https://en.cppreference.com/w/cpp/language/list_initializati...
- abbeyj 4y agoYes, it is called "Uniform Initialization". https://isocpp.org/wiki/faq/cpp11-language#uniform-init https://isocpp.org/wiki/faq/cpp11-language#uniform-init
- duped 4y agoThat's been around since C++11 although it's kind of weird to see it used for a char*
- owl57 4y agoA bit weird, but I would support a local style guide that limits initialization style choices to parens for calling non-initializer-list constructors and braces for everything else — for simplicity, consistency, less confusion with assignment, and that odd case where it would actually catch an error (unindended narrowing conversion).
- deleted 4y ago[deleted]
- devnullbrain 4y agoI use it for everything, even loop variables.