C++11 Notes 1

Source: Internet
Author: User

Directory:

1.std::share_ptr Smart pointers:

2.std::tr1::function template class:

3.stringstream:

4.set/vector/map:

5.static_cast<class > (expression);

Std::share_ptr Smart pointers:

Http://en.cppreference.com/w/cpp/memory/shared_ptr

Smart pointer shared_ptr<_class>, defined in <memory> .

A pointer representing the _class type that avoids pointer errors by means of reference counting;

Std::unique_ptr

Std::tr1::function template class:

#include <tr1/functional>

typedef std::tr1::function<void (int) > handlerevent;

In C + +, TR1 (Technology Report) contains a function template class and bind template functions. They can be used to implement functions similar to function pointers .

Function<void () > F (_f);//???

Inside the class is called the Internal class (private);

Vector<char> *data

-----Function::member-----

StringStream:

#include <sstream>

C + + introduces the Three classes of Ostringstream, Istringstream,StringStream , and to use them to create an object must contain sstream.h Header file.

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 is stored contiguously, which means that elements can is accessed not only through iterators, but also using Offsets on regular pointers to elements. This means, a pointer to an element of a vector is passed to any function that expects a pointer to an element of An array.

Map is an associative container;

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 the refer to *this.

C++11 Notes 1

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.