What do the double curly braces in the following line of C++ code mean?
piranha::symbol_set ss({{piranha::symbol(detail::poly_print(var))}});
For context, this is from a file in the SymEngine code ("symengine/polys/uintpoly_piranha.h"), which can be found at the link below, as can the Piranha library which is used in the above line.
- SymEngine source code: https://github.com/symengine/symengine
- Piranha source code: https://github.com/bluescarni/piranha
I know single curly braces are used as initializer lists, but the meaning of the double curly braces within the set of parentheses makes little sense to me.
The main thing I found on double curly braces was this post, but it does not seem applicable here.
Also, I apologize for linking source code like this but I am unsure of how to make a smaller example given my lack of understanding.
Thanks!
Curly braces can be used to describe
std::initializer_listof symbols, see the corresponding constructor)symbolusing the move constructor, see the corresponding constructor)If the type of a parameter is known beforehand, instead of
symbol{parameters}you can just write{parameters}. This also works for return values and variable initialization.So what actually happens in this line is:
std::stringis returned fromdetail::poly_print(var)piranha::symbolsymbol, constructing anothersymbolThis seems a bit redundant, but I haven't tried if the code works with only one pair of braces
piranha::symbolis then stored in astd::initializer_listpiranha::symbol_set