码迷,mamicode.com
首页 > 编程语言 > 详细

C++11笔记1

时间:2015-12-27 17:41:57      阅读:292      评论:0      收藏:0      [点我收藏+]

标签:

目录:

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++引入了ostringstreamistringstreamstringstream这三个类,要使用他们创建对象就必须包含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;

std::vector is a sequence container that encapsulates dynamic size arrays.

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.

 

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;

 

shared_ptr<T> shared_from_this();

(1)

shared_ptr<T const> shared_from_this() const;

(2)

Returns a std::shared_ptr<T> that shares ownership of *this with all existing std::shared_ptr that refer to *this.

 

C++11笔记1

标签:

原文地址:http://www.cnblogs.com/ypwen/p/5080346.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!