Metaprogramming support to rebuild and rebind variadic templates.
The sequence of variadic arguments itself is often difficult to manipulate, because a parameter pack is not a type proper in C++, but rather some meta mapping expanded immediately by the compiler. For more elaborate processing, this sequence must thus be re-mapped into a format that allows to pass partial results from recursive evaluations (since all of this »processing« is actually a form of functional programming).
For many simple cases though it is sufficient just to re-bind a template to another template's variadic sequence, possibly with some basic manipulation. Such a meta-processing can be coded very succinctly, by passing the target template to receive the altered sequence as a template-template parameter.
- Warning
- this kind of recursive remoulding typically imposes an O(n) effort during compilation, sometimes even O(n²) (notably reversing a sequence). Thus be sure to apply to short type sequences only endcode
- Usage example
template<typename...CASES>
struct MyModel
{
using SubSeq = _Vari<MyModel, CASES...>::Prefix;
MyModel (SubSeq&& subModel);
using Tuple = RebindVariadic<std::tuple, CASES...>
::Type;
}
- See also
- param-weaving-pattern.hpp "usage example"
-
util::parse::AltModel "usage example"
-
typelist.hpp
-
function.hpp
Definition in file variadic-rebind.hpp.