我正在尝试将转换应用于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需要一个Forward Sequence,而mpl::string是一个Bidirectional Sequence,我认为它是Forward Sequence的一种,所以我认为它是可行的。
我做错了什么吗,或者这是完全不可能的?如果有,原因何在?
谢谢!
发布于 2010-06-15 22:16:26
事实证明,如果我使用transform_view,它就可以工作。
https://stackoverflow.com/questions/3022494
复制相似问题