boost之function
boost中function是对函数指针和函数对象的进行封装的模板类。
定义示例:function<int()> func生成一个空的对象,表示函数参数个数为零,返回类型为int。
#include <iostream>
#include <string>
#include <vector>
#include <boost/function.hpp>
using namespace std;
using namespace boost; int f(int a,int b)
{
return a + b;
} int main()
{
function<int(int,int)> fun;//定义一个空的function对象
fun = f;//调用赋值操作符
if (fun)
{
cout << fun(10,20) <<endl;
}
fun.empty(); //清空
return 0;
}
boost之function的更多相关文章
- 借助boost bind/function来实现基于对象编程。
boost bind/function库的使用: 替换了stl中mem_fun,bind1st,bin2nd等函数.用户注册回调函数需要利用boost/bind转化成库中boost/function格 ...
- boost中Function和Lambda的使用
:first-child { margin-top: 0px; } .markdown-preview:not([data-use-github-style]) h1, .markdown-previ ...
- boost bind function用法说明
目录(?)[+] 1 bind/function 引 (1)头文件 bind函数#include <boost/bind.hpp> function使用头文件#include <bo ...
- 基于boost的bind与function的一个简单示例消息处理框架
前两年开始接触boost,boost库真是博大精深:今天简单介绍一下boost中之前用到的的bind与function,感觉挺实用的,分享给大家,我对boost用的也不多,让大家见笑了. 上次文发了一 ...
- 学习C++11的一些思考和心得(1):lambda,function,bind和委托
1.lambda表达式 lanbda表达式简单地来讲就是一个匿名函数,就是没有名称的函数,如果以前有接触过python或者erlang的人都比较熟悉这个,这个可以很方便地和STL里面的算法配合 st ...
- Timer.4 - Using a member function as a handler
In this tutorial we will see how to use a class member function as a callback handler. The program s ...
- boost 的函数式编程库 Phoenix入门学习
这篇文章是我学习boost phoenix的总结. 序言 Phoenix是一个C++的函数式编程(function programming)库.Phoenix的函数式编程是构建在函数对象上的.因此,了 ...
- boost中bind的使用
:first-child { margin-top: 0px; } .markdown-preview:not([data-use-github-style]) h1, .markdown-previ ...
- boost phoenix
In functional programming, functions are objects and can be processed like objects. With Boost.Phoen ...
随机推荐
- Elipse安装Spring Tool Suite
STS实际上是对Eclipse的Spring包装,下载STS IDE可以直接开发spring web. 但大多数人还是喜欢使用eclipse.下面就eclipse安装sts插件做个介绍. 1.首先到s ...
- LVS+keepalived实现负载均衡
背景: 随着你的网站业务量的增长你网站的服务器压力越来越大?需要负载均衡方案!商业的硬件如F5又太贵,你们又是创业型互联公司如何有效节约成本,节省不必要 的浪费?同时实现商业硬件一样的 ...
- PHP导出excel文件
现在教教你如何导入excel文件: 在我的文件储存里面有一个com文件夹的,将其解压放在ThinkPHP/Library/文件夹里面,然后就是写控制器啦!去调用这个插件: <?php names ...
- 查看SDCard是否被挂载
获取Environment.getExternalStorageState(),然后得到的字符串进行查看 //android.os.Environment.MEDIA_MOUNTED="mo ...
- jQuery ajax Load关闭缓存的方法
[导读] 在jQuery ajax Load关闭缓存的方法很简单,我们只要在$ ajaxSetup中把cache: false就楞以了,当然我们还可以使用一个随机参数来实例了.简单介绍load(url ...
- delphi 基础之三 编写和调用dll文件
delphi 编写和调用dll文件 Windows 的执行文件可以划分为两种形式程序和动态连接库 (DLLs).一般程序运行是用.EXE文件,但应用程序有时也可以调用存储在DLL的函数. 在如下几 ...
- 14.python中的集合
什么是集合?正如其字面的意思,一堆东西集中合并到一起.乍一听貌似和容器没什么差别,嗯,好吧,集合也算是一种容器. 在学习这个容器有什么不同之前,先看看集合是如何创建的: a = set() #可变集合 ...
- delphi 博客地址收藏
博客地址: Delphi XE5 for Android系列,值得入门者一读http://www.cnblogs.com/ChinaEHR/p/3346867.html http://hi.baidu ...
- Python Ogre Blender(转载)
http://www.cppblog.com/Charlib/archive/2010/05/31/python_ogre_blender_1.html PyOgre入门以及如何使用Blender制作 ...
- Power of Four
Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example:Giv ...