如何绑定变体apply_viewer
How to bind a variant apply_visitor?
我有这个(C++03)代码,但不知怎么的,bind
拒绝工作。有什么想法吗?
typedef boost::variant<int, string> Container;
std::vector<Container> v;
...
class IsBad: public boost::static_visitor<>
{
public:
typedef bool result_type;
result_type operator()(int& t) const { return i % 2; }
result_type operator()(string& s) const { return s == "foo"; }
};
IsBad isBad;
std::vector<Container>::iterator it2 =
std::find_if(it, itEnd, bind(apply_visitor(isBad, _1)));
// bool is not a class, struct or union type
您不必使用bind
,apply_visitor(isBad)
已经为您返回了一个函子。
相关文章:
- 如何通过 std::apply 调用具有定义的第一个参数的可变参数模板函数?
- 如果结果存储在变量中forward_as_tuple然后在 std::apply 中使用之前丢失右值引用
- std::apply是否为评估顺序提供保证
- registerPointPickingCallback (PCLViewer::callback_Test,(void*)&viewer);返回 C3687 非标准语法;使用"&"创建指向成员的指针
- 用std :: apply迭代元组元素
- 为什么 std::apply 使用泛型函数失败
- C++ - 使用 Windows Photo Viewer 使用 ShellExecute 打开图像
- 为什么 std::apply 可以调用 lambda 而不是等效的模板函数?
- C :查找MS PowerPoint Viewer的安装目录
- 修改后的std::invoke/std::apply,将可调用项作为void*-possible
- boost::mpl::apply 仅适用于类型化模板参数
- 来自osg::viewer的RGB图像
- 如何检查类型是否为mpl::apply-able
- std::apply可能未正确实现
- CD对话框中的Apply按钮
- std::apply和常量表达式
- 使用std::apply应用可变函数
- SWIG:如何使用%apply返回结构? 'No typemaps defined'警告