Boost logo

Boost :

Subject: [boost] [parameter] accessing param type within signature
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2010-05-09 09:51:07


Hello all,

I am new to Boost.Parameter. I am having troubles getting the
depth_first_search() example from the documentation section 2.1.5.6.2
to compile.

Was the example in section 2.1.5.6.2 even compiled? If so, can someone
point to the code that can be compiled? (I did look into Boost sandbox
libs/parameter/... but I did not see it there.)

1) I need to access graph_type to write type requirements of following
parameters.
2) The documentation section 2.1.5.6.1 says I can use graph_type (or
xyz_type in general) from within the signature to refer to the
parameter type. However, that seems not to be the case (also looking
at the preprocessed code, xyz_type is a template parameter available
only in the function body but not in the signature).
3) The documentation section 2.1.5.6.2 seems to use tag::graph::_
instead of graph_type to access the type (also sometimes
graphs::graph::_ is used but I think that might be a typo... because
the tag namespace should be there as in graphs::tag::graph::_).
4) Finally, even when I try to use tag::graph::_ to refer to
graph_type, I get the GCC error below.
What am I doing wrong?

    // File: g00.cpp
    #include <boost/parameter.hpp>

    namespace graphs {

    BOOST_PARAMETER_NAME(graph)
    BOOST_PARAMETER_NAME(graph2)

    BOOST_PARAMETER_FUNCTION(
        (void),
        depth_first_search,
        tag,
        (required
            (graph, *)
            (graph2, (tag::graph::_)) // Trying to use graph's type
here... but I can't use graph_type and graph::_ does not compile...
        )
    )
    {
        // Here I can use graph_type.
    }

    } // namespace

    int main() {
        graphs::depth_first_search(1, 2);
        return 0;
    }

$ g++ -Wall -Werror -I./src -DCONTRACT_CHECK_BLOCK_INVARIANT
-DCONTRACT_CHECK_CLASS_INVARIANT -DCONTRACT_CHECK_PRECONDITION
-DCONTRACT_CHECK_POSTCONDITION example/Own/parameter/g00.cpp
/usr/include/boost/parameter/value_type.hpp: In instantiation of
‘boost::parameter::value_type<mpl_::arg<2>, graphs::tag::graph,
boost::parameter::void_>’:
example/Own/parameter/g00.cpp:9: instantiated from ‘typename
graphs::boost_param_result_17depth_first_search<Args>::type
graphs::boost_param_impldepth_first_search(const Args&) [with Args =
boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<graphs::tag::graph2,
const int>, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<graphs::tag::graph,
const int>, boost::parameter::aux::empty_arg_list> >]’
example/Own/parameter/g00.cpp:9: instantiated from ‘typename
graphs::boost_param_result_17depth_first_search<typename
boost::parameter::aux::argument_pack<graphs::boost_param_params_17depth_first_search<int>,
const ParameterArgumentType0, const ParameterArgumentType1,
boost::parameter::void_, boost::parameter::void_,
boost::parameter::void_>::type>::type graphs::depth_first_search(const
ParameterArgumentType0&, const ParameterArgumentType1&, typename
boost::parameter::aux::match<graphs::boost_param_params_17depth_first_search<int>,
ParameterArgumentType0, ParameterArgumentType1,
boost::parameter::void_, boost::parameter::void_,
boost::parameter::void_>::type) [with ParameterArgumentType0 = int,
ParameterArgumentType1 = int]’
example/Own/parameter/g00.cpp:24: instantiated from here
/usr/include/boost/parameter/value_type.hpp:60: error: no type named
‘binding’ in ‘struct mpl_::arg<2>’
/usr/include/boost/parameter/value_type.hpp:62: error: no type named
‘binding’ in ‘struct mpl_::arg<2>’
example/Own/parameter/g00.cpp: In function ‘typename
graphs::boost_param_result_17depth_first_search<Args>::type
graphs::boost_param_impldepth_first_search(const Args&) [with Args =
boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<graphs::tag::graph2,
const int>, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<graphs::tag::graph,
const int>, boost::parameter::aux::empty_arg_list> >]’:
example/Own/parameter/g00.cpp:9: instantiated from ‘typename
graphs::boost_param_result_17depth_first_search<typename
boost::parameter::aux::argument_pack<graphs::boost_param_params_17depth_first_search<int>,
const ParameterArgumentType0, const ParameterArgumentType1,
boost::parameter::void_, boost::parameter::void_,
boost::parameter::void_>::type>::type graphs::depth_first_search(const
ParameterArgumentType0&, const ParameterArgumentType1&, typename
boost::parameter::aux::match<graphs::boost_param_params_17depth_first_search<int>,
ParameterArgumentType0, ParameterArgumentType1,
boost::parameter::void_, boost::parameter::void_,
boost::parameter::void_>::type) [with ParameterArgumentType0 = int,
ParameterArgumentType1 = int]’
example/Own/parameter/g00.cpp:24: instantiated from here
example/Own/parameter/g00.cpp:9: error: no matching function for call
to ‘boost::parameter::aux::cast<void
()(boost::parameter::value_type<mpl_::arg<2>, graphs::tag::graph,
boost::parameter::void_>)>::execute(const int&)’
/usr/include/boost/parameter/aux_/cast.hpp:99: note: candidates are:
static boost::parameter::aux::use_default_tag
boost::parameter::aux::cast<void
()(T)>::execute(boost::parameter::aux::use_default_tag) [with T =
boost::parameter::value_type<mpl_::arg<2>, graphs::tag::graph,
boost::parameter::void_>]
/usr/include/boost/parameter/aux_/cast.hpp:109: note:
static T boost::parameter::aux::cast<void ()(T)>::execute(T) [with T =
boost::parameter::value_type<mpl_::arg<2>, graphs::tag::graph,
boost::parameter::void_>]
example/Own/parameter/g00.cpp:9: error: return-statement with a value,
in function returning 'void'

$ g++ --version
g++ (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu4)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I have tried this on Boost 1.42.0 and 1.34.1 (same errors).

Thank you very much.

-- 
Lorenzo

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