重定向提升绑定
redirecting boost bind
以下转换是否可行?我已经尝试了 boost::lambda 并且只是一个普通绑定,但我正在努力在没有处理 foo 和调用栏的特殊帮助程序类的情况下就地进行转换。
struct Foo {}; // untouchable
struct Bar {}; // untouchable
// my code
Bar ConvertFooToBar(const Foo& foo) { ... }
void ProcessBar(const Bar& bar) { ... }
boost::function<void (const Foo&)> f =
boost::bind(&ProcessBar, ?);
f(Foo()); // ProcessBar is invoked with a converted Bar
你正在做函数组合。所以你必须组成你的bind
。你需要ProcessBar(ConvertFooToBar(...))
发生。所以你必须真正做到这一点。
boost::function<void (const Foo&)> f =
boost::bind(&ProcessBar, boost::bind(ConvertFooToBar, _1));
相关文章:
- 如何将stdout重定向到stderr
- 我想将一个对T类型的非常量左值引用绑定到一个T类型的临时值
- 在基于范围的for循环中使用结构化绑定声明
- 使用 LuaBridge 将 LuaJIT 绑定到C++会导致"PANIC: unprotected error"
- 尝试通过OCI例程从Oracle获取blob数据,但出现错误:ORA-01008:并非所有变量都绑定
- 在使用GPU支持编译Tensorflow时,会遇到CUDA_TOOLKIT_PATH未绑定变量
- 编写时C++中的输入重定向问题
- 视觉studo 2019中的漫画和静态/动态绑定
- 将自由函数绑定为类成员函数
- 将常量指针引用绑定到非常量指针
- 在派生类中绑定非静态模板化成员函数
- 绑定派生类方法C++从实例范围之外的分隔 std::function 变量调用
- 在 openGL 中多次绑定缓冲区
- 定义有趣的宏和正则表达式在Z3 C++绑定
- 使用结构化绑定'Reflection'
- 获取通过重定向传入的输入文件的名称?
- 为什么 std::绑定错误参数可以成功?
- 如何绑定 C++ gRPC 客户端的网络接口
- 在 openmp 中,omp_get_thread_num是否绑定到物理线程?
- 重定向提升绑定