+types · threaderic/examples@0aaf69f · GitHub
Skip to content

Commit 0aaf69f

Browse files
committed
+types
1 parent 74e91d4 commit 0aaf69f

4 files changed

Lines changed: 73 additions & 3 deletions

File tree

‎cpp/03.cpp‎

Lines changed: 16 additions & 0 deletions

‎cpp/11.cpp‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,24 @@ void dynamic_memory_11()
336336
#endif
337337
/// @endcond
338338

339+
void types_11()
340+
{
341+
static_assert(__cpp_decltype);
342+
343+
int a;
344+
decltype(a) b;
345+
346+
static_assert(is_same<decltype(a), decltype(b)>::value);
347+
static_assert(!is_same<decltype(a), unsigned>::value);
348+
static_assert(is_same<int, int32_t>::value);
349+
static_assert(is_same<signed, int32_t>::value);
350+
351+
static_assert(is_integral<int>::value);
352+
static_assert(is_integral<bool>::value);
353+
static_assert(!is_integral<float>::value);
354+
static_assert(is_pointer<int*>::value);
355+
356+
}
339357
/// @}
340358

341359
int main(void)
@@ -350,6 +368,8 @@ int main(void)
350368
sort_11();
351369
dynamic_memory_11();
352370
static_assert(constexpr_factorial(4));
371+
372+
types_11();
353373
return 0;
354374
}
355375
/// @}

‎cpp/14.cpp‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,21 @@ void sort_14()
156156
);
157157
}
158158

159+
void types_14()
160+
{
161+
static_assert(is_null_pointer< decltype(nullptr) >::value);
162+
static_assert(is_null_pointer< nullptr_t >::value);
163+
static_assert(__cpp_decltype);
164+
static_assert(is_integral<int>());
165+
166+
// https://en.cppreference.com/w/cpp/language/auto
167+
int a = 0;
168+
decltype(auto) a_copy = a;
169+
assert(&a_copy != &a);
170+
decltype(auto) a_ref = (a);
171+
assert(&a_ref == &a);
172+
173+
}
159174
/// @}
160175

161176
int main(void)
@@ -169,6 +184,7 @@ int main(void)
169184
implicit_return_type();
170185
dynamic_memory_14();
171186
sort_14();
187+
types_14();
172188

173189
return 0;
174190
}

‎cpp/17.cpp‎

Lines changed: 21 additions & 3 deletions

0 commit comments

Comments
 (0)