1

我正在尝试将转换应用于mpl::string,但无法编译。我正在使用 MS VC++2010 和 Boost 1.43.0。编码:

#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;

}

我已在http://paste.ubuntu.com/447759/上发布了完整的错误消息。

MPL 文档说mpl::transform需要 a Forward Sequence,并且mpl::string是 a Bidirectional Sequence,我认为它是一种Forward Sequence,所以我认为它会起作用。

我做错了什么,还是这完全不可能?如果是这样,为什么?

谢谢!

4

1 回答 1

1

事实证明,如果我使用transform_view.

于 2010-06-15T14:16:25.680 回答