【发布时间】:2014-10-15 18:17:05
【问题描述】:
我之前问过一个关于使用 lambda 实现类似功能的问题,但 wasn't able to get this working 所以我尝试使用仿函数来解决问题。无论如何,这可能更整洁,因为它不涉及构造std::function 对象并且更接近example case set out in the documentation。
这是一个简单的设置来说明我的问题:
#include <boost/range/adaptor/transformed.hpp>
#include <vector>
// some structure
template <typename T>
struct MyStruct
{
MyStruct(T t)
{
}
};
template <typename T>
struct Converter
{
using return_type = MyStruct<T>;
return_type operator()(const T& value)
{
return return_type(value);
}
};
int main(int argc, const char* argv[])
{
std::vector<int> vec {1, 2, 3};
auto val = vec | boost::adaptors::transformed(Converter<int>());
return 0;
}
当我尝试编译时,我收到以下错误消息:
/home/user/packages/boost/mpl/eval_if.hpp:38:31: error: no type named 输入“
boost::mpl::eval_if<boost::is_same<boost::use_default, boost::use_default>, boost::result_of<const Converter<int>(int&)>, boost::mpl::identity<boost::use_default> >::f_ {aka struct boost::result_of<const Converter<int>(int&)>}”
我不知道该怎么做。我无法在代码中发现任何错误。有什么想法吗?
【问题讨论】: