Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2001-03-29 08:21:50


I just intuit that it works something like this:

struct default {};
struct base {
    typedef default weight_type;
    typedef default visitor_type;
};

// make a similar visitor_t template
template <class T, class B = base>
struct weight_map_t : B {
  typedef weight_map_t<T,B> self;

  template <class V>
  visitor_t<V, self> visitor(const V& v)
  {
    return visitor_t<V,self>(v, *this)
  }

  weight_map_t(const T& arg, B = base())
    : m_value(arg) {}

  const T& m_value;
};

template <class T>
weight_map_t<T> weight_map(const T& x) {
  return weight_map_t<T>(x);
}

I hope this quick sketch helps!

-Dave
----- Original Message -----
From: "Jeremy Siek" <jsiek_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Thursday, March 29, 2001 12:30 AM
Subject: Re: [boost] Boost.Graph suggestions

>
> Are there any good articles written on how to do this named parameter
> thing for template functions? If not, would someone explain to me how it
> works?
>
> On Sun, 25 Mar 2001, David Abrahams wrote:
>
> abraha> I have 3. The one interesting one is the idea of using a named
parameters
> abraha> interface for some of the algorithms. For example, the only way to
pass a
> abraha> WeightMap to dijkstra_shortest_paths is to use the version of the
algorithm
> abraha> that takes all 7 possible parameters! If instead, the algorithm
could be
> abraha> invoked thus,
> abraha>
> abraha> dijkstra_shortest_paths(g, start,
> abraha> weight_map(my_weights).visitor(my_visitor))
> abraha>
> abraha> the interface would be far simpler.
> abraha>
> abraha> The other two are more mundane suggestions for the docs:
> abraha>
> abraha> 1. Put a link to the TOC prominently at the top of the
introduction page.
> abraha> It's a bit buried, and some people want to go directly to a user
manual to
> abraha> get a survey of features.
> abraha>
> abraha> 2. Begin using "Boost.Graph" or "boost::graph" instead of "BGL".
> abraha>
> abraha> -Dave
> abraha>
> abraha>
> abraha> To unsubscribe, send email to:
<mailto:boost-unsubscribe_at_[hidden]>
> 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
> ----------------------------------------------------------------------
>
>
>
> To unsubscribe, send email to: <mailto:boost-unsubscribe_at_[hidden]>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>


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