Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#3226 closed Bugs (invalid)

boost::fusion sequence fails to work in boost::mpl::fold

Reported by: Jeffrey Hellrung <jhellrung@…> Owned by:
Milestone: Boost 1.40.0 Component: fusion
Version: Boost 1.39.0 Severity: Problem
Keywords: Cc:

Description

The following results in a compiler error (boost 1.39, MSVC 9) at the line where boost::mpl::fold is applied to fusion_vector_type. Commenting this line out makes the code compile.

#include <boost/fusion/container/vector.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/fold.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/type_traits/is_void.hpp>

int main(int argc, char* argv[])
{
    typedef boost::fusion::vector< int > fusion_vector_type;
    typedef boost::mpl::vector< int > mpl_vector_type;
    typedef boost::mpl::fold< fusion_vector_type, void, boost::mpl::_1 >::type void1_type;
    typedef boost::mpl::fold< mpl_vector_type, void, boost::mpl::_1 >::type void2_type;
    BOOST_MPL_ASSERT((boost::is_void< void2_type >));
    return 0;
}

Is this a problem with boost::fusion::vector failing some requirement of being a boost::mpl sequence, or of boost::mpl::fold using something outside the stated requirements of boost::mpl sequences?

I've attached the compiler output.

  • Jeff

Attachments (1)

compiler_output.txt (2.0 KB ) - added by Jeffrey Hellrung <jhellrung@…> 13 years ago.

Download all attachments as: .zip

Change History (4)

by Jeffrey Hellrung <jhellrung@…>, 13 years ago

Attachment: compiler_output.txt added

comment:1 by Jeffrey Hellrung <jhellrung@…>, 13 years ago

Here's a similar example using a somewhat simpler boost::mpl metafunction:

#include <boost/fusion/container/vector.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/type_traits/is_void.hpp>

int main(int argc, char* argv[])
{
    typedef boost::fusion::vector< void > fusion_vector_type;
    typedef boost::mpl::vector< void > mpl_vector_type;
    //typedef boost::mpl::front< fusion_vector_type >::type void1_type;
    typedef boost::mpl::front< mpl_vector_type >::type void2_type;
    BOOST_MPL_ASSERT((boost::is_void< void2_type >));
    return 0;
}

FWIW, boost::mpl::find_if appears to work fine on boost::fusion sequences...

comment:2 by Steven Watanabe, 13 years ago

Component: Nonefusion
Resolution: invalid
Status: newclosed

You're missing a header.

#include <boost/fusion/include/mpl.hpp>

comment:3 by Jeffrey Hellrung <jhellrung@…>, 13 years ago

Ah, I see; great! Is that the most finely-grained header to include to enable the use of fusion sequences as MPL sequences?

The only MPL-related headers I had remembered reading about in the docs were for adapting MPL sequences to be used as fusion sequences, and a spot check right now didn't find anything else. I might be blind. Is this use (enabling fusion sequences to be used in MPL algorithms) mentioned somewhere in the documentation?

Thanks.

Note: See TracTickets for help on using tickets.