C++ features by examples
Collaboration diagram for Other:

Functions

static void demo ()
 
void types_14 ()
 

Variables

template<typename T >
pi = T(3.141592653589793238462643383)
 Binary literals, digit separators. More...
 
template<>
const char * pi< const char * > = "pi"
 

Detailed Description

TODO:

https://en.cppreference.com/w/cpp/container/map/find

https://en.cppreference.com/w/cpp/language/constexpr

https://en.cppreference.com/w/cpp/language/integer_literal

https://en.cppreference.com/w/cpp/language/function // decltype(auto)

https://en.cppreference.com/w/cpp/language/aggregate_initialization

https://en.cppreference.com/w/cpp/thread/shared_timed_mutex

https://en.cppreference.com/w/cpp/thread/shared_lock

https://en.cppreference.com/w/cpp/utility/integer_sequence

https://en.cppreference.com/w/cpp/utility/exchange

https://en.cppreference.com/w/cpp/utility/forward

https://en.cppreference.com/w/cpp/io/manip/quoted

[[deprecated]]

Function Documentation

◆ demo()

static void demo ( )
static

Standard user-defined literals

Definition at line 107 of file 14.cpp.

108{
109 assert(pi<int> == 3);
110 assert(string(pi<const char*>) == "pi");
111
112 auto binary_literal = 0b0100'1100'0110;
113
114 auto integer_literal = 1'000'000;
115
116 auto floating_point_literal = 0.000'015'3;
117
119
120 auto str = "hello world"s; // auto deduces string
121 auto dur = 60s; // auto deduces chrono::seconds
122
123}
const char * pi< const char * >
Definition: 14.cpp:105
Here is the caller graph for this function:

◆ types_14()

void types_14 ( )

Definition at line 125 of file 14.cpp.

126{
127 static_assert(is_null_pointer<decltype(nullptr)>::value);
128 static_assert(is_null_pointer<nullptr_t>::value);
129 static_assert(__cpp_decltype);
130 static_assert(is_integral<int>());
131
132 // Tuple addressing via type
133 tuple<string, string, int> tuple_by_type("foo", "bar", 7);
134
135 int i = get<int>(tuple_by_type);
136 assert(i == 7);
137
138 int j = get<2>(tuple_by_type);
139 assert(j == 7);
140
141 // https://en.cppreference.com/w/cpp/language/auto
142 int a = 0;
143 static_assert(__cpp_decltype_auto);
144 decltype(auto) a_copy = a;
145 assert(&a_copy != &a);
146 decltype(auto) a_ref = (a);
147 assert(&a_ref == &a);
148
149 // https://en.cppreference.com/w/cpp/memory/unique_ptr/make_unique
150 //auto u = unique_ptr<int>(new int(1));
151 auto u = make_unique<int>(1);
152 assert(u);
153 assert(*u == 1);
154 auto ua = make_unique<int[]>(3);
155}
int & a_ref(int &a)
https://en.cppreference.com/w/cpp/language/reference
Definition: 03.cpp:209
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ pi

template<typename T >
T pi = T(3.141592653589793238462643383)

Binary literals, digit separators.

Template variables https://en.cppreference.com/w/cpp/language/variable_template Numeric pi

Definition at line 100 of file 14.cpp.

◆ pi< const char * >

template<>
const char* pi< const char * > = "pi"

Definition at line 105 of file 14.cpp.