boost::bind模仿程序
来源:互联网 发布:西门子plc解密软件 编辑:程序博客网 时间:2024/05/11 16:51
#include <iostream>#include <vector>#include <algorithm>#include <string>#include <functional>#include <numeric>//#include <boost/bind.hpp>namespace{class placeholder {};placeholder _1;}template <typename R,typename T, typename Arg>class simple_bind_t{public:typedef R (T::*fn)(Arg);simple_bind_t(fn f,const T& t):fn_(f),t_(t){}R operator()(Arg a){return (t_.*fn_)(a);}private:fn fn_;T t_;};template <typename R, typename T, typename Arg>simple_bind_t<R,T,Arg> simple_bind( R (T::*fn)(Arg), const T& t, const placeholder&){std::cout << typeid(R).name() << std::endl<< typeid(T).name() << std::endl<< typeid(Arg).name() << std::endl;return simple_bind_t<R,T,Arg>(fn,t);}class Test{public:void do_stuff(const std::vector<int>& v){std::copy(v.begin(),v.end(),std::ostream_iterator<int>(std::cout," "));}};template <typename R,typename T,typename Arg>int my_mem_fun(R (T::*f)(Arg)){std::cout << typeid(R).name() << std::endl<< typeid(T).name() << std::endl<< typeid(Arg).name() << std::endl;return 1;}class Cla1{public:std::vector<int> fun1(float val){return std::vector<int>();}};int main(){Test t;std::vector<int> vec;vec.push_back(42);vec.push_back(55);vec.push_back(88);simple_bind(&Test::do_stuff,t,_1)(vec);my_mem_fun(&Cla1::fun1);}
- boost::bind模仿程序
- 编程模仿boost::function和boost::bind
- boost.bind
- boost::bind
- boost::bind
- boost::bind
- Boost::bind
- Boost::bind
- bind -boost
- boost::bind()
- boost bind
- boost::bind
- boost::bind
- boost::bind
- boost bind
- boost::bind
- boost::bind()
- boost::bind
- html
- 404
- 错误 Android requires compiler compliance level 5.0. Please fix project properties.
- 使用JQuery实现Edit in place效果的Input框
- 答疑解惑:为什么要把SWAP设置到手机内置闪存中?
- boost::bind模仿程序
- SSH学习笔记(三)
- 嵌入式系统的知识体系、学习误区及学习建议
- 设计模式C++实现(1)——工厂模式
- xml命名空间
- Y Combinator的演示日:终极综述
- Ajax+Jquery+Json,ASP.NET分页,存储过程分页
- android中shortcut
- 优化大师客户端:完成了一部分,中途停电一次,有几个丢失了,剩下的感兴趣的可以完成