wiki/index.php?title=Template:cpp/meta/navbar_content&action=edit)

C++ provides metaprogramming facilities, such as type traits, compile-time
rational arithmetic, and compile-time integer sequences.

##  Contents

  * 1  Definitions 
  * 2  Type traits 
    * 2.1  Base classes 
    * 2.2  Unary type traits 
      * 2.2.1  Primary type categories 
      * 2.2.2  Composite type categories 
      * 2.2.3  Type properties 
      * 2.2.4  Supported operations 
    * 2.3  Property queries 
    * 2.4  Type relationships 
    * 2.5  Type transformations 
      * 2.5.1  Const-volatility specifiers 
      * 2.5.2  References 
      * 2.5.3  Sign modifiers 
      * 2.5.4  Arrays 
      * 2.5.5  Pointers 
      * 2.5.6  Other transformations 
    * 2.6  Logical operations 
    * 2.7  Member relationships 
  * 3  Compile-time rational arithmetic 
  * 4  Compile-time integer sequences 

  
---  
  
###  [ [ edit ](/mwiki/index.php?title=cpp/meta&action=edit&section=1 "Edit
section: Definitions") ]  Definitions

The following types are collectively called _referenceable types_ :

  * [ object types ](/w/cpp/language/type#Object_type "cpp/language/type")
  * [ function types ](/w/cpp/language/function#Function_type "cpp/language/function") without  cv  and  ref 
  * [ reference types ](/w/cpp/language/reference "cpp/language/reference")

For any referenceable type ` T ` , a reference to it can be created  [1]  .

  1. ↑  For reference types, this can be done via [ reference collapsing ](/w/cpp/language/reference#Reference_collapsing "cpp/language/reference") . 

###  [ [ edit ](/mwiki/index.php?title=cpp/meta&action=edit&section=2 "Edit
section: Type traits") ]  Type traits

Type traits define compile-time template-based interfaces to query the
properties of types.

Attempting to specialize a template defined in the [ ` <type_traits> `
](/w/cpp/header/type_traits "cpp/header/type traits") header and listed in
this page results in undefined behavior, except that  [ std::common_type
](/w/cpp/types/common_type "cpp/types/common type") and [ `
std::basic_common_reference ` ](/w/cpp/types/common_reference
"cpp/types/common reference") (since C++20)  may be specialized as required in
description.

A template defined in the [ ` <type_traits> ` ](/w/cpp/header/type_traits
"cpp/header/type traits") header may be instantiated with an incomplete type
unless otherwise specified, notwithstanding the general prohibition against
instantiating standard library templates with incomplete types.

####  [ [ edit ](/mwiki/index.php?title=cpp/meta&action=edit&section=3 "Edit
section: Base classes") ]  Base classes

Most of non-transforming type traits need to be publicly and unambiguously
derived from  std::integeral_constant  in order to satisfy the requirements of
[ UnaryTypeTrait  ](/w/cpp/named_req/UnaryTypeTrait "cpp/named
req/UnaryTypeTrait") or [ BinaryTypeTrait  ](/w/cpp/named_req/BinaryTypeTrait
"cpp/named req/BinaryTypeTrait") .

Defined in header ` [ <type_traits> ](/w/cpp/header/type_traits
"cpp/header/type traits") `  
---  
[ integral_constant  bool_constant  ](/w/cpp/types/integral_constant "cpp/types/integral constant") (C++11)  (C++17)  |  compile-time constant of specified type with specified value   
(class template)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/types/dsc_integral_constant&action=edit)  
  
Two specializations of  [ std::integral_constant
](/w/cpp/types/integral_constant "cpp/types/integral constant") for the type
bool  are provided:

Defined in header ` [ <type_traits> ](/w/cpp/header/type_traits
"cpp/header/type traits") `  
---  
Type  |  Definition   
` true_type ` |  [ std::  integral_constant  ](http://en.cppreference.com/w/cpp/types/integral_constant) < bool  ,  true  >  
` false_type ` |  [ std::  integral_constant  ](http://en.cppreference.com/w/cpp/types/integral_constant) < bool  ,  false  >  
  
####  [ [ edit ](/mwiki/index.php?title=cpp/meta&action=edit&section=4 "Edit
section: Unary t