在编译的代码:

struct any_type: boost::tuple<std::string, std::string, std::string> {
   ...
};

struct functor {
   void operator()(const std::string& v) {
      std::cout << v << std::endl;
   }
};

int main() {
   any_type type;
   boost::fusion::for_each(type, functor());
}

得到误差:无类型命名为“类别”在“结构any_type” 为什么? 我希望它从boost.tuple继承。

有帮助吗?

解决方案

继承boost::fusion::tuple代替boost::tuple。结果 注意:考虑使void operator()(const std::string& v)常量

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top