default template params

Hi all, I know the Boost.Parameter allows advanced defaults when dealing with templated parameters - for templated classes. But shouldn't we have a simple interface, like this: struct default_ {}; template<class param, class default_type> struct use_default { typedef param type; }; template<class default_type> struct use_default<default_, default_type> { typedef default_type type; }; Example: template<class formatter_base = default_, class destination_base = default_, class f_ptr = default_, class d_ptr = default_ > struct logger { typedef use_default<formatter_base, formatter::base<> > ::type formatter_type; typedef use_default<destination_base, destination::base<> > ::type destination_type; typedef use_default<f_ptr, formatter_type* > f_ptr_type; typedef use_default<d_ptr, destination_type* > d_ptr_type; ... }; This way, if can specify only the params I want, specifying "default_" for the rest: logger< some_formatter> l; logger< default_, some_destination> l2; logger< some_fmt, default_, shared_ptr<some_fmt> > l3; ... Best, John -- http://John.Torjo.com -- C++ expert ... call me only if you want things done right

on Thu Nov 01 2007, John Torjo <john.groups-AT-torjo.com> wrote:
Hi all,
I know the Boost.Parameter allows advanced defaults when dealing with templated parameters - for templated classes. But shouldn't we have a simple interface, like this:
...<snip>...
if can specify only the params I want, specifying "default_" for the rest:
logger< some_formatter> l; logger< default_, some_destination> l2; logger< some_fmt, default_, shared_ptr<some_fmt> > l3;
typedef boost::parameter::void_ default_; should give you what you want. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com

I saw the void_ class. However, what's the boost counterpart of my use_default class? Best, John
on Thu Nov 01 2007, John Torjo <john.groups-AT-torjo.com> wrote:
Hi all,
I know the Boost.Parameter allows advanced defaults when dealing with templated parameters - for templated classes. But shouldn't we have a simple interface, like this:
...<snip>...
if can specify only the params I want, specifying "default_" for the rest:
logger< some_formatter> l; logger< default_, some_destination> l2; logger< some_fmt, default_, shared_ptr<some_fmt> > l3;
typedef boost::parameter::void_ default_;
should give you what you want.
-- http://John.Torjo.com -- C++ expert ... call me only if you want things done right

on Thu Nov 01 2007, John Torjo <john.groups-AT-torjo.com> wrote:
I saw the void_ class.
However, what's the boost counterpart of my use_default class?
boost::parameter::binding<...> See http://www.boost-consulting.com/boost/libs/parameter/doc/html/index.html#arg... -- Dave Abrahams Boost Consulting http://www.boost-consulting.com
participants (2)
-
David Abrahams
-
John Torjo