views:

93

answers:

1

Hi,

I'm trying to apply a transformation to an mpl::string, but can't get it to compile. I'm using MS VC++2010 and Boost 1.43.0. The code:

#include <boost/mpl/string.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/transform.hpp>
#include <boost/mpl/plus.hpp>
#include <boost/mpl/arithmetic.hpp>

using namespace boost;

int main() {

    // this compiles OK
    typedef mpl::vector_c<int, 'abcd', 'efgh'> numbers;
    typedef mpl::transform<numbers, mpl::plus<mpl::_1, mpl::int_<1> > >::type result_numbers;

    // this doesn't (error C2039: 'value' : is not a member of 'boost::mpl::has_push_back_arg')
    typedef mpl::string<'abcd', 'efgh'> chars;
    typedef mpl::transform<chars, mpl::plus<mpl::_1, mpl::int_<1> > >::type result_chars;

}

I've posted the full error message at http://paste.ubuntu.com/447759/.

The MPL docs say that mpl::transform needs a Forward Sequence, and mpl::string is a Bidirectional Sequence, which I gather is a type of Forward Sequence, so I thought it'd work.

Am I doing something wrong, or is this outright impossible? If so, why?

Thanks!

+1  A: 

Turns out that it works if I use transform_view.

Pedro d'Aquino
This problem was due to a bug in Boost.MPL, and will be fixed in the next release: http://lists.boost.org/boost-users/2010/06/60002.php
Pedro d'Aquino