Share via


integral_constant Class

Makes integral constant fromt type and value.

template <class Ty, Ty v>
    struct integral_constant;

Parameters

  • Ty
    The type of the constant.

  • Ty
    The value of the constant.

Remarks

The template class, when specialized with an integral type and a value of that type, represents an object that holds a constant of that integral type with the specified value.

Example

 

// std_tr1__type_traits__integral_constant.cpp 
// compile with: /EHsc 
#include <type_traits> 
#include <iostream> 
 
int main() 
    { 
    std::cout << "integral_constant<int, 5> == " 
        << std::tr1::integral_constant<int, 5>::value << std::endl; 
    std::cout << "integral_constant<bool, false> == " << std::boolalpha 
        << std::tr1::integral_constant<bool, false>::value << std::endl; 
 
    return (0); 
    } 
 

integral_constant<int, 5> == 5 integral_constant<bool, false> == false

Requirements

Header: <type_traits>

Namespace: std::tr1

See Also

Reference

<type_traits>

false_type Typedef

true_type Typedef