#include "named_param.hh" #include "typelist.hh" #include #include struct print_policy_tag {}; struct dec_print_policy {}; struct hex_print_policy {}; struct promote_policy_tag {}; struct precise_promote_policy {}; struct stdc_promote_policy {}; template::type> class ntp_test { private: // The user-provided parameter tag/type map. typedef Policies policy_typelist; // Find the pair corresponding to the print policy and extract // the given type, or the default (dec_print_policy) if it is not there. typedef typename mpl::extract_named_param_or_default:: template apply::result print_policy; // Ditto for the promotion policy. typedef typename mpl::extract_named_param_or_default:: template apply::result promote_policy; public: ntp_test(void) { std::cout << typeid(*this).name() << std::endl; std::cout << "Print policy: " << typeid(print_policy).name() << std::endl; std::cout << "Promote policy: " << typeid(promote_policy).name() << std::endl; }; }; int main(void) { // Default print and promote policies ntp_test<> defaults; // Default promote policy ntp_test::result>::type> default_promote; // Alternateively: // ntp_test >::type> // default_promote; // Default print policy ntp_test::result>::type> default_print; // Alternateively: // ntp_test >::type> // default_print; return(0); }