Title: Theory / Unimportant / CS / Programming / C++ / Manual / Norm / 28 Metaprogramming
On every note of this deck, unless a note says otherwise:
Language: C++

Name: metaprogramming.
Definition: Programming that manipulates program entities, such as classes and functions
Page: 779
Chapter: 28
Section: 1

Question: Advantage of metaprogramming
Answer: It allow or more specific type, leading to more type safety
Page: 780
Chapter: 28
Section: 1
Answer2: with compile-time computed value, some function can be chosen at compile time instead of runtime

Name: A type function
Definition: A function that either takes at least one type argument or produces at least one
type as a result
Page: 781
Chapter: 28
Section: 2
Context: C++
Example: sizeof(T) return the size of a value of type T
Example2: is_polymorphic<T>::value
Example3: std::conditional<predicate, true_value, false_value>::type
Example4: Integer<N>::type return an integer allowing to store N bytes

Question: How to avoid to repeat long sentences such as
typename actual_important_type<parameters>::type
Answer: template<typename T>
using some_name = typename actual_important_type<T>::type;
and uses some_name<parameters> everywhere
Page: 784
Chapter: 28
Section: 2.1
Context: C++

Instruction: typename std::conditional<C, T, F>::type
Page: 784
Chapter: 28
Section: 2.1
Returns: If C is true, then T else F
Intuition: Useful for type parameter

Page: 784
Implementation: template<template<typename...> class F, typename ... Args>
using T? = F<Args...>;
Section: 2.1
Chapter: 28
Effect: Introduce a delay function, such that T?<U, ARG_1, ..., ARG_N> is similar to U<ARG_1, ..., ARG_N> but only created when it is needed
Language: C++
Intuition: Useful if
U<ARG_1, ..., ARG_N>
is potentially an ilegal type that would raise a compile time error, but is not actually used

Name: A trait
Definition: associate properties with a type
Page: 784
Chapter: 28
Section: 2.2
Context: c++
Example: template<typename Iterator>
struct iterator_traits {
  using difference_type = typename Iterator::difference_type;
  using value_type = typename Iterator::value_type;
  using pointer = typename Iterator::pointer;
  using reference = typename Iterator::reference;
  using iterator_category = typename Iterator::iterator_category;
};

Instruction: is_void<X>
Page: 1018
Chapter: 35
Section: 4
Returns: is X void?

Instruction: is_integral<X>
Page: 1018
Chapter: 35
Section: 4
Returns: is X an integral type?

Instruction: is_floating_point<X>
Page: 1018
Chapter: 35
Section: 4
Returns: is X a floating-point type?

Instruction: is_array<X>
Page: 1018
Chapter: 35
Section: 4
Returns: is X a built-in array?

Instruction: is_pointer<X>
Page: 1018
Chapter: 35
Section: 4
Returns: is X a pointer (not including pointers to memberrs)

Instruction: is_lvalue_reference<X>
Page: 1018
Chapter: 35
Section: 4
Returns: is X a l_value reference?

Instruction: is_rvalue_reference<X>
Page: 1018
Chapter: 35
Section: 4
Returns: is X an rvalue reference?

Instruction: is_member_object_&ointer<X>
Page: 1018
Chapter: 35
Section: 4
Returns: is X a pointer to a non-static data member?

Instruction: is_member_function_pointer<X>
Page: 1018
Chapter: 35
Section: 4
Returns: is X a pointer to a non-static data function?

Instruction: is_enum<X>
Page: 1018
Chapter: 35
Section: 4
Returns: is X an enum or a class enum

Instruction: is_union<X>
Page: 1018
Chapter: 35
Section: 4
Returns: is X a union

Instruction: is_class<X>
Page: 1018
Chapter: 35
Section: 4
Returns: is X a class or strucs (but not enums)

Instruction: is_function<X>
Page: 1018
Chapter: 35
Section: 4
Returns: is X a function

Instruction: is_const<X>
Page: 1020
Chapter: 35
Section: 4
Returns: is X a const

Instruction: is_volatile<X>
Page: 1020
Chapter: 35
Section: 4
Returns: is X a volatile

Instruction: is_trivial<X>
Page: 1020
Chapter: 35
Section: 4
Returns: is X a trivial type

Instruction: is_trivially_copyable<X>
Page: 1020
Chapter: 35
Section: 4
Returns: is X a trivially copyable type

Instruction: is_standard_layout<X>
Page: 1020
Chapter: 35
Section: 4
Returns: is X a standrd-layout type

Instruction: is_pod<X>
Page: 1020
Chapter: 35
Section: 4
Returns: is X a plain old data type

Instruction: is_litetarl_type<X>
Page: 1020
Chapter: 35
Section: 4
Returns: does X have a constexpr constructor

Instruction: is_empty<X>
Page: 1020
Chapter: 35
Section: 4
Returns: does X have a member that requires space in an object

Instruction: is_polymorphic<X>
Page: 1020
Chapter: 35
Section: 4
Returns: does X have a virtual function

Instruction: is_abstract<X>
Page: 1020
Chapter: 35
Section: 4
Returns: does X have a pure virtual function

Instruction: is_signed<X>
Page: 1020
Chapter: 35
Section: 4
Returns: Is X an arithmetic type and signed

Instruction: is_unsigned<X>
Page: 1020
Chapter: 35
Section: 4
Returns: Is X an arithmetic type and unsigned

Instruction: is_constructible<X, args>
Page: 1020
Chapter: 35
Section: 4
Returns: Can an X be constructed from args

Instruction: is_default_constructible<X>
Page: 1020
Chapter: 35
Section: 4
Returns: Can an X be constructed from {}

Instruction: is_copy_constructible<X>
Page: 1020
Chapter: 35
Section: 4
Returns: Can an X be constructed from an X&

Instruction: is_move_constructible<X>
Page: 1020
Chapter: 35
Section: 4
Returns: Can an X be constructed from an X&&

Instruction: is_assignable<X, Y>
Page: 1020
Chapter: 35
Section: 4
Returns: Can a Y be assigned to an X

Instruction: is_copy_assignable<X>
Page: 1020
Chapter: 35
Section: 4
Returns: Can a X& be assigned to an X

Instruction: is_move_assignable<X>
Page: 1020
Chapter: 35
Section: 4
Returns: Can a X&& be assigned to an X

Instruction: is_destructible<X>
Page: 1020
Chapter: 35
Section: 4
Returns: Can an X be destroyed

Instruction: is_trivially_foo<X, args>
Page: 1021
Chapter: 35
Section: 4
Returns: is_foo<X, args> and doing so only use trivial operations

Instruction: is_nothrow_foo<X, args>
Page: 1021
Chapter: 35
Section: 4
Returns: is_foo<X, args> using only noexcept operations

Instruction: rank<X>
Page: 1021
Chapter: 35
Section: 4
Returns: the number of dimension of X as an array (0 if it is not an array)

Instruction: extent<X, N>
Page: 1021
Chapter: 35
Section: 4
Returns: If X is an array, the number of elements in the N-th dimension. 0 if it is not an array

Page: 1021
Syntactic sugar: extent<X>
Implementation: extent<X, 0>
Language: C++
Section: 4
Chapter: 35

Instruction: is_same<X, Y>
Page: 1022
Chapter: 35
Section: 4
Returns: Is X the same type as Y

Instruction: is_base_of<X, Y>
Page: 1022
Chapter: 35
Section: 4
Returns: Is X a base of Y

Instruction: is_convertible<X, Y>
Page: 1022
Chapter: 35
Section: 4
Returns: Can an X be implicitly converted to a Y

Instruction: remove_volatile<X>
Page: 1022
Chapter: 35
Section: 4.2
Returns: X, without any top-level volatile

Instruction: remove_cv<X>
Page: 1022
Chapter: 35
Section: 4.2
Returns: X, without any top-level const or volatile

Instruction: add_cv<X>
Page: 1022
Chapter: 35
Section: 4.2
Returns: add const and volatile if they are missing

Instruction: add_const<X>
Page: 1022
Chapter: 35
Section: 4.2
Returns: const X if X has no const, else X

Instruction: add_volatile<X>
Page: 1022
Chapter: 35
Section: 4.2
Returns: volatile X if X has no volatile, else X

Instruction: add_lvalue_reference<X>
Page: 1022
Chapter: 35
Section: 4.2
Returns: if X = Y&&, then Y&, otherwise X&

Instruction: add_rvalue_reference<X>
Page: 1022
Chapter: 35
Section: 4.2
Returns: if X is a reference, X, otherwise X&&

Instruction: remove_reference<X>
Page: 1022
Chapter: 35
Section: 4.2
Returns: if X is a refernece type, the referred-to type, otherwise X

Instruction: decay<X>
Page: 1022
Chapter: 35
Section: 4.2
Returns: The type passed by value for a function argument of type X

Instruction: make_signed<X>
Page: 1024
Chapter: 35
Section: 4.2
Returns: remove any explicit or implied unsigned modifier and add signed to X
Assuming: X integral but not bool nor enum

Instruction: make_unsigned<X>
Page: 1024
Chapter: 35
Section: 4.2
Returns: remove any explicit or implied signed modifier and add unsigned to X
Assuming: X integral but not bool nor enum

Instruction: remove_extent<X>
Page: 1024
Chapter: 35
Section: 4.2
Returns: if X is an array type, the element type; otherwise X

Instruction: remove_all_extent<X>
Page: 1024
Chapter: 35
Section: 4.2
Returns: if X is an array type, the base type (after removing all array modifiers); otherwise X

Instruction: remove_pointer<X>
Page: 1024
Chapter: 35
Section: 4.2
Returns: If X is a poniter type, the pointed-to type; otherwise X

Page: 1024
Syntactic sugar: add_pointer<X>
Implementation: remove_reference<X>::type*
Language: C++
Section: 4.2
Chapter: 35

Typ: aligned_storage<n, a>
Meaning: a POD type with size of at least n and whose alignemnt is a divisor of a
Page: 1025
Language: C++
Chapter: 35
Section: 4.2

Page: 1025
Syntactic sugar: aligned_storage<n>
Implementation: aligned_storage<n, def> where def is the largest alignment required for any object type, T, with sizeof(T)<=n
Language: C++
Section: 4.2
Chapter: 35

Typ: aligned_storage<n, X...>
Meaning: A POD type with size of at least n that can hold a union with members of type X
Page: 1025
Language: C++
Chapter: 35
Section: 4.2

Typ: enable_if<b,X>
Meaning: X if b==true; otherwise substitution failure
Page: 1025
Language: C++
Chapter: 35
Section: 4.2

Page: 1025
Syntactic sugar: enable_if<b>
Implementation: enable_if<b, void>
Language: C++
Section: 4.2
Chapter: 35

Typ: common_type<X>
Meaning: The common type of all types of a parameter pack X ;
two types are common if they can be used as true
and false types of a ?: -expression
Page: 1025
Language: C++
Chapter: 35
Section: 4.2

Typ: underlying_type<X>
Meaning: the underlying type of X
Page: 1025
Language: C++
Chapter: 35
Section: 4.2
Assuming: X is an enumeration

Typ: result_of<FX>
Meaning: The type of the result of F(X) ; FX must be
a type F(X) where F is invoked with an argument list X
Page: 1025
Language: C++
Chapter: 35
Section: 4.2

Typ: declval<T>
Meaning: the type of an unevaluated variable of type T .
Page: 1026
Language: C++
Chapter: 35
Section: 4.2