std::meta::is_arithmetic_type
From cppreference.com
| Defined in header <meta>
|
||
consteval bool is_arithmetic_type( std::meta::info r );
|
(since C++26) | |
Returns true if r represents an arithmetic type (that is, an integral type or a floating-point type) or a cv-qualified version thereof. Otherwise returns false.
Parameters
| r | - | a reflection value |
Return value
true if r represents an arithmetic type; otherwise false.
Exceptions
Throws std::meta::exception if r does not represent a type or type alias.
Example
Run this code
#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() {}
See also
(C++26) |
checks if reflected type is an integral type (function) |
(C++26) |
checks if reflected type is a floating-point type (function) |
(C++11) |
checks if a type is an arithmetic type (class template) |