Spec-Zone.ru › C++

std::meta::is_scalar_type

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

Returns true if r represents a scalar type. Otherwise returns false.

Parameters

r - a reflection value

Return value

true if r represents a scalar type; otherwise false.

Exceptions

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

Example

#include <cstddef>
#include <meta>

enum E {};

struct S
{
    int mem{};
    int foo();
};
using mem_obj_ptr_t = int S::*;
using mem_fun_ptr_t = int (S::*)();

static_assert
(""
    and   is_scalar_type(^^E)
    and ! is_scalar_type(^^S)
    and   is_scalar_type(^^int)
    and ! is_scalar_type(^^int&)
    and   is_scalar_type(^^int*)
    and ! is_scalar_type(^^void)
    and   is_scalar_type(^^void*)
    and   is_scalar_type(^^float)
    and ! is_scalar_type(^^float&)
    and   is_scalar_type(^^float*)
    and ! is_scalar_type(^^float[42])
    and   is_scalar_type(add_cv(^^int))
    and   is_scalar_type(^^mem_obj_ptr_t)
    and   is_scalar_type(^^mem_fun_ptr_t)
    and   is_scalar_type(^^std::nullptr_t)
    and   is_scalar_type(^^decltype(^^::))
    and   is_scalar_type(^^std::meta::info)
);

int main() {}

See also

is_arithmetic_type
(C++26)
checks if reflection represents an arithmetic type
(function)
is_enum_type
(C++26)
checks if reflected type is an enumeration type
(function)
is_pointer_type
(C++26)
checks if reflected type is a pointer type
(function)
is_member_pointer_type
(C++26)
checks if reflection represents a member pointer type
(function)
is_null_pointer_type
(C++26)
checks if reflected type is std::nullptr_t
(function)
is_reflection_type
(C++26)
checks if reflected type is std::meta::info
(function)
is_object_type
(C++26)
checks if reflected type is an object type
(function)
is_scalar
(C++11)
checks if a type is a scalar type
(class template)

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

Spec-Zone.ru

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