Boost logo

Boost :

From: Cromwell Enage (sponage_at_[hidden])
Date: 2006-02-09 09:42:56


I've implemented a new macro, BOOST_PARAMETER_FUN2,
that uses approach #3 mentioned in
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1385.htm>.
 For example, the BGL implementation of Dijkstra's
algorithm
<http://www.boost.org/libs/graph/doc/dijkstra_shortest_paths.html>
can now be declared as:

struct dijkstra_parameters
  : parameter::parameters<...>
{
}

BOOST_PARAMETER_FUN2(
    void
  , dijkstra_shortest_paths
  , (0)(0)(1)(1)(0)(0)(0)(0)(0)(0)(1)(1)
  , 2
  , dijkstra_parameters
)
{
    ...
}

Each element in the Boost.Preprocessor sequence
corresponds to a positional argument. If the element
is set to 1, the argument is bound to an "out"
parameter; otherwise it is bound to an "in" parameter.
 The size of the sequence is, of course, the total
number of arguments accepted by the function.

The macro argument following the sequence is the
number of parameters required by the function. All
other macro arguments are the same as the
corresponding ones in BOOST_PARAMETER_FUN.

The macro and example program are available in the
"_Examples" directory of the Boost Vault, filename
"boost_parameter_fun2_example.zip". GCC 3.4.2 (MinGW)
compiles it cleanly, but MSVC 7.1 emits several
instances of "warning C4003: not enough actual
parameters for macro 'BOOST_PP_SEQ_SIZE_I'". (I know
I shouldn't be passing BOOST_PP_EMPTY() to it, but
replacing it with BOOST_PP_SEQ_NIL generates errors
from both compilers.

                              Fixes appreciated!
                              Cromwell D. Enage

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


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