Картинка для печати(кликабельно):
В шпаргалке содержатся следующие таблицы:
auto |
auto p = new T(); |
auto p = make_shared<T>(arg1); |
auto my_lambda= [](){}; |
auto it = m.begin(); |
[attr colspan="2"]
standard types |
int8_t |
uint8_t |
int16_t |
uint16_t |
int32_t |
uint32_t |
int64_t |
uint64_t |
raw string literals |
string test=R»(C:\A\B\file1.txt)»; |
null pointer constant |
void foo(char*); |
void foo (int); |
foo(nullptr);//calls first foo |
delegating constructors |
class A |
{ |
int a; |
public: |
A(int x) {a = x;} |
A() : A(42){} |
A(string s) : A(stoi(s)){} |
}; |
static_assert |
template<class T> |
void f(T v){ |
static_assert(sizeof(v) == 4, |
#171;#187; «v must have size of 4 bytes»); |
} |
decltype |
int i = 0; |
decltype(i) var1; |
decltype(2+3) var2; |
in-class member initializers |
class A |
{ |
int a = 5; |
string h = «text1»; |
#8230;
}; |
override & final |
struct Base |
{ |
vitrual void f(float); |
virtual void f2() final; |
}; |
sruct Derived : Base |
{ |
void f(int) override; //error |
void f2(); //error |
}; |
lambdas |
int a = 42; |
count_if(v.begin(), v.end(), |
[&a](int x){return x==a;}); |
std::tuple |
tuple<int,float>t(1,2.f); |
int x = get<0>(t); |
float y = get<1>(t); |
enum class |
enum class Alert {green, red}; |
enum class Color:int {red, blue}; |
Alert a =7; //error |
Color c =7; //error |
int a2 = red; //error |
in a3 = Alert::red; //error |
int a4 = blue; //error |
int a5 = Color::blue; //error |
Color a6 = Color::blue; //ok |
Взято с официального блога компании Инфопульс Украина
Комментарии: