Reputation: 1532
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.
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!
Upvotes: 9
Views: 3763
Reputation: 5421
Curly braces can be used to describe
std::initializer_list
of symbols, see the corresponding constructor) symbol
using the move constructor, see the corresponding constructor)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::string
is returned from detail::poly_print(var)
piranha::symbol
symbol
, constructing another symbol
piranha::symbol
is then stored in a std::initializer_list
piranha::symbol_set
Upvotes: 7