diff --git a/include/boost/detail/named_template_params.hpp b/include/boost/detail/named_template_params.hpp index 10cdba4..9e56c5b 100644 --- a/include/boost/detail/named_template_params.hpp +++ b/include/boost/detail/named_template_params.hpp @@ -69,7 +69,35 @@ namespace boost { // To differentiate an unnamed parameter from a traits generator // we use is_convertible. struct named_template_param_base { }; + + template + struct is_named_param_list { + enum { value = is_convertible::value }; + }; + struct choose_named_params { + template struct bind { typedef Prev type; }; + }; + struct choose_default_arg { + template struct bind { + typedef detail::default_argument type; + }; + }; + template struct choose_default_dispatch { }; + template <> struct choose_default_dispatch { + typedef choose_named_params type; + }; + template <> struct choose_default_dispatch { + typedef choose_default_arg type; + }; + + template + struct choose_default_argument { + enum { is_named = is_named_param_list::value }; + typedef typename choose_default_dispatch::type Selector; + typedef typename Selector::template bind::type type; + }; + // This macro assumes that there is a class named default_##TYPE // defined before the application of the macro. This class should // have a single member class template named "bind" with two @@ -85,9 +113,10 @@ namespace boost { struct get_##TYPE##_from_named { \ template \ struct bind { \ - typedef typename NamedParams::traits::TYPE TYPE; \ + typedef typename NamedParams::traits NamedTraits; \ + typedef typename NamedTraits::TYPE TYPE; \ typedef typename resolve_default::type type; \ + default_##TYPE, Base, NamedTraits>::type type; \ }; \ }; \ struct pass_thru_##TYPE { \ @@ -106,7 +135,7 @@ namespace boost { }; \ template \ class get_##TYPE { \ - enum { is_named = is_convertible::value }; \ + enum { is_named = is_named_param_list::value }; \ typedef typename get_##TYPE##_dispatch::type Selector; \ public: \ typedef typename Selector::template bind::type type; \