|
Boost : |
From: Jeremy Siek (jsiek_at_[hidden])
Date: 2001-03-05 22:43:39
Hmm, I think I missed a turn in the road earlier on ;)
Are you suggesting the following?
template <class Base,
class Policies,
class ValueOrNamedParameters = boost::detail::default,
class ReferenceOrNamedParameters = boost::detail::default,
...>
class iterator_adaptor;
and could then be used like the old way:
iterator_adaptor<int*, default_iterator_policies, int, int&, ...>
and could also be used like this:
iterator_adaptor<int, default_iterator_policies,
iterator_traits_builder
::reference<int>
::iterator_category<std::input_iterator_tag>
On Mon, 5 Mar 2001, David Abrahams wrote:
abraha>
abraha> ----- Original Message -----
abraha> From: "Jeremy Siek" <jsiek_at_[hidden]>
abraha>
abraha> > A good goal... but I don't know how to achieve it.
abraha>
abraha> The rough outline goes like this:
abraha>
abraha> 1. Instead of the current default values for e.g., Reference, use some tag
abraha> type, say boost::detail::default.
abraha> 2. Write a template is_named_parameters<T> that can detect whether a type is
abraha> built using the named parameters technique. Shouldn't be too hard, I think.
abraha> 3. Write a template select_named_parameters<T,U,V,W,X>::type that selects
abraha> the named parameter type among its arguments**. If there are no named
abraha> parameters in the args, returns a traits type where everything is
abraha> boost::detail::default.
abraha> 4. Synthesize the reference type something like this (pseudocode):
abraha> typedef typename select_named_parameters<Value, Reference, Category,
abraha> Distance, Pointer>::type named_params;
abraha> typedef (named_params::reference == default && Reference == default) ?
abraha> iterator_defaults<Base,Value>::reference
abraha> : named_params::reference != default
abraha> ? Reference != default ? ERROR : named_params::reference
abraha> : Reference;
abraha>
abraha> Make any sense?
abraha>
abraha> -Dave
abraha>
abraha>
abraha> **You could also write merge_named_parameters<T,U> and chain them for
abraha> completeness, but this is probably good enough, and simpler.
abraha>
abraha>
abraha>
abraha>
abraha> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
abraha>
abraha>
abraha>
----------------------------------------------------------------------
Jeremy Siek www: http://www.lsc.nd.edu/~jsiek/
Ph.D. Candidate email: jsiek_at_[hidden]
Univ. of Notre Dame work phone: (219) 631-3906
----------------------------------------------------------------------
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk