Spec-Zone.ru › C++

std::meta::is_integral_type

Defined in header <meta>
consteval bool is_integral_type( std::meta::info r );
(since C++26)

Returns true if r represents an integral type, that is, any of bool, char, char8_t, char16_t, char32_t, wchar_t, short, int, long, longlong, or any implementation-defined extended integer types, including any signed, unsigned, and cv-qualified variants. Otherwise returns false.

Parameters

r - a reflection value

Return value

true if r represents an integral type; otherwise false.

Exceptions

Throws std::meta::exception if r does not represent a type or type alias.

Example

#include <meta>

static_assert
(""
    && is_integral_type(^^float) == false
    && is_integral_type(^^int*) == false
    && is_integral_type(^^int) == true
    && is_integral_type(add_cv(^^long)) == true
    && is_integral_type(^^bool) == true
    && is_integral_type(^^char) == true
);

class A {};
static_assert(is_integral_type(^^A) == false);

struct B { int x: 4; };
static_assert(is_integral_type(^^B) == false);

using BF = decltype(B::x); // bit-field's type
static_assert(is_integral_type(^^BF) == true);

enum E : int {};
static_assert(is_integral_type(^^E) == false);

static_assert(is_integral_type(^^decltype(+[]{})) == false);

int main() {}

See also

is_arithmetic_type
(C++26)
checks if reflection represents an arithmetic type
(function)
is_floating_point_type
(C++26)
checks if reflected type is a floating-point type
(function)
is_fundamental_type
(C++26)
checks if reflection represents a fundamental type
(function)
is_scalar_type
(C++26)
checks if reflected type is a scalar type
(function)
integral
(C++20)
specifies that a type is an integral type
(concept)
is_integer
[static]
identifies integer types
(public static member constant of std::numeric_limits<T>)
is_integral
(C++11)
checks if a type is an integral type
(class template)
is_floating_point
(C++11)
checks if a type is a floating-point type
(class template)
is_arithmetic
(C++11)
checks if a type is an arithmetic type
(class template)
is_enum
(C++11)
checks if a type is an enumeration type
(class template)

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/meta/is_integral_type

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API