What is the `(... && TraitsOf())` mean in C++

Viewed 59
1 Answers

HaversackTs is a parameter pack, which means it contains some variable number of types given to the template. ... expands a template parameter pack, using a given binary operator (in our case, the bitwise |) to fold over it. So if, in a particular instantiation of this template, HaversackTs happened to be int, std::string, then that line would mean

constexpr auto all_deps_type_set =
    (TraitsOf(types::type_c<int>).all_deps | TraitsOf(types::type_c<std::string>).all_deps);

The right-hand side is expanded separately for each type in the parameter pack, and the results are combined using |. This generalizes naturally to more than two arguments by simply applying | between each one.

Related