流水账7.19

来源:互联网 发布:淘宝运营猝死 编辑:程序博客网 时间:2024/05/07 07:06

1.

 

std:tr1::function

 

-----------------what's "std:tr1::function"?--------------------

Use the std::tr1::function Class to Generalize Callbacks

 

or a C++ programmer, the term "a callback function" means at least three different things: a pointer to a freestanding function (i.e., a C function), a pointer to a member function, or a function object. However, in high level programming, these technical minutiae just get in the way. What you need is a generalized abstraction mechanism that can encapsulate any callable entity regardless of its underlying implementation. The recently standardized std::tr1::function class template offers exactly that. It's a generic callback mechanism with intuitive and uniform syntax and semantics. This article will show you how to use this class template.

 

简译:

对于C++编程人员来说,“回调函数”这个术语通常意味着三种不同的事物:

一个指向独立函数的指针(例如,一个C函数),一个指向成员函数的指针,或者,一个函数对象

然而,在高水平编程中,这些细节只会成为阻碍。你需要的是一个一般化的抽象机制,这种机制可以封装任何可调用的实体,而不管其内部的实现机制。最近标准化的std::tr1::function模板类就是这样的,它是一个有着直观和统一的语法和语义的通用回调机制。

 


How do you generalize the concept of callbacks while maintaining similar syntax and semantics to function pointers?

 


Use std::tr1::function class template as a generic wrapper for all callable entities.

 

其余部分见

http://www.devx.com/cplus/10MinuteSolution/32455/0/page/1

 

2.