-
Notifications
You must be signed in to change notification settings - Fork 0
/
notes.txt
59 lines (42 loc) · 2.3 KB
/
notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
nullptr:
- keyword and a pointer literal(instance of type std::nullptr_t)
- it is a prvalue (pure rvalue), So you cannot take the address of nullptr, (eg, &5, &10, &nullptr not allowed)
- integeral null pointer constanst can be converted to nulptr_t but not the vice versa
- int a = reinterpret_cast<int>(nullptr) has same value as (void*)0 to int type
- can be initialized to bool (bool a = nullptr)
- <cstddef>
- http://en.cppreference.com/w/cpp/types/nullptr_t
- http://en.cppreference.com/w/cpp/language/nullptr
- NullPtr.cc
Generic Selection: C11
- Provides a way to choose one of several expressions at compile time, based on a type of a controlling expression
- _Generic ( controlling-expression , association-list ) where association-list = type-name : expression
Static_assert:
- assert.h
- static_assert(bool_constexpr, message)
type_triats:
- type_traits
- the resulting values are available at compile time itself. So combining them with static_assert will be powerful
- This header defines a series of classes to obtain type information on compile-time.
The header contains:
Helper classes: Standard classes to assist in creating compile-time constants.
Type traits: Classes to obtain characteristics of types in the form of compile-time constant values.
Type transformations: Classes to obtain new types by applying specific transformations to existing types.
- You can also write type triats to have some functions which are not provided by the standard library
- Refer: TypeTriats.cc
type_alias:
- similar to typedef, but useful when dealing with templates.. basically can be templated
- Eg. template <typename T> using myVector = std::vector<T>;
- Refer : type_alias.cc
explicit keyword on conversion objects:
- explicit operator <type_name>() { }
- example:
- class A { explicit operator int () {} };
- A a; int i = (int)a;
Non static Class Member Initializer:
- Refer: http://en.cppreference.com/w/cpp/language/data_members
- Members can be initialized in 2 ways
- [1] member-initializer list.. (the one we give in constructors)
[2] brace-or-equal initializer.. this holds the temporaries, used when we declare the members
- If a member is defined in member initializer list, then the temporaries (if any) assiged using brace initializer will be overridden
#This is a dummy commit