Spec-Zone.ru › C++

std::meta::is_arithmetic_type

Объявлено в заголовочном файле <meta>
consteval bool is_arithmetic_type( std::meta::info r );
(начиная с C++26)

Возвращает true, если r представляет арифметический тип (то есть целочисленный тип или тип с плавающей точкой) либо его cv-квалифицированную версию. В противном случае возвращает false.

Параметры

r - значение отражения

Возвращаемое значение

true, если r представляет арифметический тип; в противном случае — false.

Исключения

Выбрасывает std::meta::exception, если r не представляет тип или псевдоним типа.

Пример

#include <atomic>
#include <cstddef>
#include <meta>

class A {};

enum class B : int { e };

static_assert
(""
    and is_arithmetic_type(^^bool)
    and is_arithmetic_type(^^char)
    and is_arithmetic_type(^^char const)
    and is_arithmetic_type(^^int)
    and is_arithmetic_type(^^int const)
    and is_arithmetic_type(^^float)
    and is_arithmetic_type(^^float const)

    and not is_arithmetic_type(^^char&)
    and not is_arithmetic_type(^^char*)
    and not is_arithmetic_type(^^int&)
    and not is_arithmetic_type(^^int*)
    and not is_arithmetic_type(^^float&)
    and not is_arithmetic_type(^^float*)
    and not is_arithmetic_type(^^A)
    and not is_arithmetic_type(^^B)
    and not is_arithmetic_type(^^decltype(B::e))
    and not is_arithmetic_type(^^std::byte)
    and not is_arithmetic_type(^^std::atomic_int)
);

int main() {}

См. также

is_integral_type
(C++26)
проверяет, является ли отражённый тип целочисленным типом
(функция)
is_floating_point_type
(C++26)
проверяет, является ли отражённый тип типом с плавающей точкой
(функция)
is_arithmetic
(C++11)
проверяет, является ли тип арифметическим
(шаблон класса)

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

Spec-Zone.ru

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