Boost logo

Boost :

Subject: Re: [boost] [parameter] type requirement compiler error
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2011-11-06 14:12:06


On Sat, Nov 5, 2011 at 7:17 AM, Lorenzo Caminiti <lorcaminiti_at_[hidden]> wrote:
> Please someone help :)

I looked into Boost.Parameter tests and
boost/libs/parameter/test/deduced_dependent_predicate.cpp uses
tag::x::_ so I modified the example to the following that compiles:

#include <boost/parameter.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/add_pointer.hpp>
#include <iostream>

BOOST_PARAMETER_NAME(x)
BOOST_PARAMETER_NAME(y)

BOOST_PARAMETER_FUNCTION(
    (int),
    f,
    tag,
    (required
        (x, *)
        (y, *(boost::is_same<boost::mpl::_1, tag::x::_>))
    )
) {
    std::cout << x << " " << y << std::endl;
    return 0;
}

int main ( void )
{
    f(1, 2);
    return 0;
}

However, this does not solves the original problem with DFS because
the following still does not compile:

        (root_vertex, // Specified type.
                *(boost::is_same<boost::mpl::_1, typename

boost::graph_traits<tag::graph::_>::vertex_descriptor>), //(2)
                *boost::vertices(graph).first)

You get the same error if you try to manipulate the tag::x::_ type
from the example above:

#include <boost/parameter.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/add_pointer.hpp>
#include <iostream>

BOOST_PARAMETER_NAME(x)
BOOST_PARAMETER_NAME(y)

BOOST_PARAMETER_FUNCTION(
    (int),
    f,
    tag,
    (required
        (x, *)
        (y, *(boost::is_same<boost::mpl::_,
                boost::add_pointer<tag::x::_>::type>)) // (2)
    )
) {
    std::cout << x << " " << y << std::endl;
    return 0;
}

int main ( void )
{
    int* p;
    f(1, p);
    return 0;
}

A far as I can tell, there are two major issues here that should be
fixed in Boost.Parameter:
1) The docs don't mention tag::xyz::_ at all, they refer to xyx_type
which only works within the function definition and not in the
function declaration.
2) The change from x_type to tag::xyz::_ broke the ability to
manipulate the parameter type in the function declaration. For
example, it broke the ability for Boost.Parameter to program the DFS
interface. This seems a major feature that was lost and
Boost.Parameter should be fixed to regain such a feature. BTW, why was
x_type changed to tag::xyx::_? What's the benefit for that?

I hope my assessment below is incorrect and someone will be able to
tell me how to program (1) and (2) using tag::xyz::_.

Thanks.
--Lorenzo


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