How to apply an mpl::transform to an mpl::string?
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> > &开发者_高级运维gt;::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!
Turns out that it works if I use transform_view
.
精彩评论