Boost logo

Boost :

From: Cromwell Enage (sponage_at_[hidden])
Date: 2004-11-26 15:22:36

In the course of refactoring my multi-state mazes
library to use Boost.NamedParams, I discovered that I
couldn't create a default predecessor map without the
proper vertex type, and I couldn't get that type
without knowing the type of the input graph. So I
went ahead and created a metafunction called
find_named_param that helped me to accomplish this

For example, you have the following tag types for your
key words:

    struct input_graph_t;
    struct input_index_map_t;

Then in your function, you can extract your types like

    typedef typename find_named_param<
                     , input_graph_t
    typedef typename find_named_param<
                     , input_index_map_t
                     , property_map<
                       , vertex_index_t

Thus, given the following keywords:

    keyword<input_graph_t> input_graph;
    keyword<input_index_map_t> input_index_map;

Assignment becomes less tedious:

      in_g = p[input_graph];
      index_map = p[
                  | get(vertex_index_t(), in_g)

The third template parameter in find_named_param is
the type whose member typedef ::type will be returned
if the named parameter is unspecified. Of course,
leaving this template parameter unspecified will
result in a compile-time error if the function
requires the named parameter. The corresponding
argument type should be the same as (or
assignment-compatible with) the type of the default
value of the named parameter.

The changes made to <boost/named_params.hpp>, in
addition to effectively removing the dependency on

    typedef H head_type;
    typedef T tail_type;

out of the conditional macro body while remaining in
detail::list, and adding the necessary functionality
to make find_named_param work.

I wouldn't call it sufficiently tested; however, the
attached program works under MinGW (GCC 3.2) and MSVC

                              Happy Thanksgiving!
                              Cromwell Enage

Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.

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