NumCpp  2.12.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
StaticAsserts.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include <type_traits>
31
33
34// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
35#define STATIC_ASSERT_VALID_DTYPE(dtype) \
36 static_assert(nc::is_valid_dtype_v<dtype>, "Template type is not a valid dtype for NdArray")
37
38// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
39#define STATIC_ASSERT_ARITHMETIC(dtype) \
40 static_assert(std::is_arithmetic_v<dtype>, "Can only be used with arithmetic types")
41
42// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
43#define STATIC_ASSERT_INTEGER(dtype) static_assert(std::is_integral_v<dtype>, "Can only be used with integer types")
44
45// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
46#define STATIC_ASSERT_UNSIGNED_INTEGER(dtype) \
47 static_assert(std::is_integral_v<dtype> && std::is_unsigned_v<dtype>, "Can only be used with integer types")
48
49// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
50#define STATIC_ASSERT_FLOAT(dtype) static_assert(std::is_floating_point_v<dtype>, "Can only be used with float types")
51
52// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
53#define STATIC_ASSERT_COMPLEX(dtype) static_assert(nc::is_complex_v<dtype>, "Can only be used with std::complex types")
54
55// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
56#define STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype) \
57 static_assert(std::is_arithmetic_v<dtype> || nc::is_complex_v<dtype>, \
58 "Can only be used with arithmetic types or std::complex types")