Boost logo

Boost :

From: John Torjo (john.groups_at_[hidden])
Date: 2007-11-01 12:19:46

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; };


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
  typedef use_default<destination_base, destination::base<> > ::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;


-- -- C++ expert
... call me only if you want things done right

Boost list run by bdawes at, gregod at, cpdaniel at, john at