Sorry for the pompous name, I would like to create a function constexprthat takes a variable number of logical arguments to the template and returns the "index of the template" of the first value truein C ++ 11 (C ++ 14 only decisions are welcome, but will not be accepted as an answer).
For example, calling this function Selector
Selector< false, false >() == 0 // none of the template argument is true
Selector< true, false, true >() == 1 // first true template argument is the first one
Selector< false, false, true, false >() == 3 // .. and here it the third one
A typical use of this and the reason I call it a "type selector" would be
Selector< std::is_pointer<T>::value, std::is_arithmetic<T>::value >()
and the reason I would like it to be constexprfor use in a partial specialized specialization.
I'm not quite sure how to do this, although I think that using variable templates, a specialized specialized construction (for case 0) and recursion (is it possible to "consume" template arguments, for example shiftin bash?), This should be feasible.
source
share