C++11笔记1
2015-12-27 16:35
246 查看
目录:
1.std::share_ptr智能指针:
2.std::tr1::function模板类:
3.stringstream:
4.set/vector/map:
5.static_cast<class > (expression);
std::share_ptr智能指针:
http://en.cppreference.com/w/cpp/memory/shared_ptr
智能指针shared_ptr<_class>,在<memory>中定义。
表示_class类型的指针,通过引用计数的方式避免指针错误;
std::unique_ptr
std::tr1::function模板类:
#include <tr1/functional>
typedef std::tr1::function<void (int)> HandlerEvent;
在C++的TR1中(Technology Report)中包含一个function模板类和bind模板函数,使用它们可以实现类似函数指针的功能。
function<void()> f(_f);//???
在类的内部叫上Internal类(private);
vector<char> *data
-----function::member-----
stringstream:
#include <sstream>
C++引入了ostringstream、istringstream、stringstream这三个类,要使用他们创建对象就必须包含sstream.h头文件。
set/vector/map:
#include <set>
#include <map>
#include <vector>
set::insert(object);
std::vector
std::vector is a sequence container that encapsulates dynamic size arrays.
map是关联式容器;
static_cast<class > (expression):
meaning:
return EventManager*'s object equal arg;
static_cast<new_type> (expression);
#include <algrithm>
pop *_Frist to *(_Last-1) and reheap,using _Pred;
shared_from_this();
std::enable_shared_from_this::shared_from_this;
Returns a std::shared_ptr<T> that shares ownership of *this with all existing std::shared_ptr that refer to *this.
1.std::share_ptr智能指针:
2.std::tr1::function模板类:
3.stringstream:
4.set/vector/map:
5.static_cast<class > (expression);
std::share_ptr智能指针:
http://en.cppreference.com/w/cpp/memory/shared_ptr
智能指针shared_ptr<_class>,在<memory>中定义。
表示_class类型的指针,通过引用计数的方式避免指针错误;
std::unique_ptr
std::tr1::function模板类:
#include <tr1/functional>
typedef std::tr1::function<void (int)> HandlerEvent;
在C++的TR1中(Technology Report)中包含一个function模板类和bind模板函数,使用它们可以实现类似函数指针的功能。
function<void()> f(_f);//???
在类的内部叫上Internal类(private);
vector<char> *data
-----function::member-----
stringstream:
#include <sstream>
C++引入了ostringstream、istringstream、stringstream这三个类,要使用他们创建对象就必须包含sstream.h头文件。
set/vector/map:
#include <set>
#include <map>
#include <vector>
set::insert(object);
std::vector
Defined in header <vector> |
template< class T, class Allocator = std::allocator<T> > class vector; |
The elements are stored contiguously, which means that elements can be accessed not only through iterators, but also using offsets on regular pointers to elements. This means that a pointer to an element of a vector may be passed to any function that expects a pointer to an element of an array. |
static_cast<class > (expression):
meaning:
return EventManager*'s object equal arg;
static_cast<new_type> (expression);
#include <algrithm>
pop *_Frist to *(_Last-1) and reheap,using _Pred;
shared_from_this();
std::enable_shared_from_this::shared_from_this;
shared_ptr<T> shared_from_this(); | (1) |
shared_ptr<T const> shared_from_this() const; | (2) |
相关文章推荐
- C++学习笔记38——智能指针
- c++11 constexpr常量表达式
- [c++ 温故知新] c++ 头文件和cpp文件关系
- c++14对内存分配性能的重大优化
- C++11 auto关键字介绍
- GC基本算法及C++GC机制
- getchar()函数使用要点
- C++中引用(&)的用法和应用实例
- 有n个整数,指定位置m处插入g个值(用指针和函数)
- C++小题(四)
- C++习题 虚函数-计算图形面积
- C/C++中const关键字详解
- C++学习:构造函数
- C++之路起航——标准模板库(queue)
- C++,清楚明白的解释
- 关于STL中trivial destroctor的小记
- C语言学习笔记------伊能C语言学习笔记-----外部函数
- [LeetCode-230]Kth Smallest Element in a BST
- C语言学习笔记-------伊能C语言学习笔记------静态函数初步
- 《C++ Primer》读书笔记之第15章:面向对象编程