Home - acolomitchi/MPinCPP GitHub Wiki
-
Template type variadic pack transformation - the
com::caffeineowl::arg_pack_trn
template
File:arg_pack_trn.hpp
Takes a variadicdestination
template and atransform
(also variadic) one and returns atype
defined as thedestination
parametrized with all the types resulted by applying the transformation
More details in here - Type replacing - the
com::caffeineowl::replace_type
template
File:replace_type.hpp
Implements the exercise 2.1 in "C++ Template Metaprogramming" with a C++11 syntax and using variadic template parameters.
Write a ternary metafunction `replace_type<c,x,y>` that takes an arbitrary compound type `c` as its first parameter, and replaces all occurrences of a type `x` within `c` with `y`:Unlike the original problem, the challenge was to make `replace_type` template handle type replacement in functions with arbitrary numbers of parameters - of course it uses [`arg_pack_trn`](#arg_pack_trn).typedef replace_type< void*, void, int >::type t1; // int*You can limit the function types you operate on to those with fewer than two arguments.typedef replace_type< int const*[10] , int const , long
::type t2; // long* [10]
typedef replace_type< char& (*)(char&) , char& , long&
::type t3; // long& (*)(long&)