Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2001-03-05 22:45:43


----- Original Message -----
From: "Jeremy Siek" <jsiek_at_[hidden]>

> A good goal... but I don't know how to achieve it.

The rough outline goes like this:

1. Instead of the current default values for e.g., Reference, use some tag
type, say boost::detail::default.
2. Write a template is_named_parameters<T> that can detect whether a type is
built using the named parameters technique. Shouldn't be too hard, I think.
3. Write a template select_named_parameters<T,U,V,W,X>::type that selects
the named parameter type among its arguments**. If there are no named
parameters in the args, returns a traits type where everything is
boost::detail::default.
4. Synthesize the reference type something like this (pseudocode):
typedef typename select_named_parameters<Value, Reference, Category,
Distance, Pointer>::type named_params;
typedef (named_params::reference == default && Reference == default) ?
    iterator_defaults<Base,Value>::reference
    : named_params::reference != default
        ? Reference != default ? ERROR : named_params::reference
        : Reference;

Make any sense?

-Dave

**You could also write merge_named_parameters<T,U> and chain them for
completeness, but this is probably good enough, and simpler.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk