libstdc++: Variable Templates

libstdc++

Variable Templates
Utilities » Metaprogramming
Collaboration diagram for Variable Templates:

## Variables
template<typename _Tp, typename _Up>
constexpr strong_ordering | std::type_order_v
template<typename _Tp, typename _Up>
constexpr bool | std::is_layout_compatible_v
template<typename _Base, typename _Derived>
constexpr bool | std::is_pointer_interconvertible_base_of_v

## Detailed Description

Since
  C++17

Each trait in <type_traits> that has a value static data member is also available as a variable template, using the same name with a _v suffix. For example, std::is_integral_v<T> is a bool constant with the same value as std::is_integral<T>::value.

In some cases, using the variable template instead of the value member avoids instantiating the class template for the trait. This gives the compiler less work to do and can make your code compile a little faster.

## Variable Documentation

## ◆ is_layout_compatible_v

template<typename _Tp, typename _Up>

bool std::is_layout_compatible_v
| constexpr

Since
  C++20

Definition at line 4063 of file type_traits.

## ◆ is_pointer_interconvertible_base_of_v

template<typename _Base, typename _Derived>

bool std::is_pointer_interconvertible_base_of_v
| constexpr

Since
  C++20

Definition at line 4091 of file type_traits.

## ◆ type_order_v

template<typename _Tp, typename _Up>

strong_ordering std::type_order_v
| inlineconstexpr

Since
  C++26

Definition at line 1279 of file compare.