Opened 13 years ago

Closed 8 years ago

#3225 closed Bugs (fixed)

boost::fusion sequence throws compiler error when used with boost::mpl::is_sequence

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

Description

The boost::fusion documentation states in the Introduction section

"Fusion sequences are fully conforming MPL sequences ..."

It seems incorrect, then, that the following code does not compile (boost version 1.39 with MSVC 9):

#include <boost/fusion/container/vector.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/is_sequence.hpp>

int main(int argc, char* argv[])
{
    typedef boost::fusion::vector1< int > vector_type;
    static const bool b = boost::mpl::is_sequence< vector_type >::value;
    return 0;
}

Would someone please explain what the deal is?

The compiler output is attached.

I have found both boost::fusion and boost::mpl (otherwise) extremely useful!

Thanks!

  • Jeff

Attachments (1)

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

Download all attachments as: .zip

Change History (6)

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

Attachment: compiler_output.txt added

compiler output

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

I'm also not having any luck using boost::fusion::vector with boost::mpl::fold and boost::mpl::find_if, so as a workaround for the moment I'll write an explicit conversion metafunction to boost::mpl::vector...

comment:2 by Joel de Guzman, 13 years ago

You should probably ask the MPL authors. The thing is: boost::mpl::is_sequence is not a requirement to be a valid MPL sequence:

http://www.boost.org/doc/libs/1_39_0/libs/mpl/doc/refmanual/forward-sequence.html

as for fold and find_if, you need to provide a test case, add another trac ticket for those.

I would suggest though to work initially with mpl sequences and only convert to a fusion sequence (e.g using fusion::as_vector) only when necessary. Fusion sequences have more overhead compared with mpl sequences because of its runtime aspects.

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

Thanks for the quick reply!

My intent was to provide a compile-time check that the types within the boost::fusion sequence satisfied certain properties. Any boost::mpl-compatible code could thus be used for such checks, but some of the code I've written using boost::mpl has asserts that the sequences satisfy boost::mpl::is_sequence. Otherwise, I would indeed construct the type sequence through boost::mpl and at the end convert it to a boost::fusion sequence, as suggested in the documentation.

It's not just that a boost::fusion sequence fails to satisfy boost::mpl::is_sequence, but that attempting to apply a boost::fusion sequence to boost::mpl::is_sequence results in a compiler error, which is not the case for other non-boost::mpl-sequence types (I think). The compiler error looks somewhat similar to what happens when trying to apply boost::mpl::fold to a fusion sequence, so I'll post a trac ticket for that code example and see what you think before forwarding these problems onto boost::mpl.

comment:4 by Joel de Guzman, 13 years ago

If there is code that relies on boost::mpl::is_sequence within MPL or outside, then, I'd say it is a bug. The requirements for a fully conforming MPL sequence is clearly stated in the reference (http://tinyurl.com/qy376b), and mpl::is_sequence is not one of the requirements.

I think this needs to be discussed in the Boost list. I'd love to be corrected, if I'm wrong.

comment:5 by Joel de Guzman, 8 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.