Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
numeric_limits.hpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
10#pragma once
11
21#include <limits>
22
23namespace shambase {
24
25 template<class T>
26 constexpr T get_max() {
27 static_assert(
29 "this type was not implemented in shambase::details::numeric_limits");
31 }
32
33 template<class T>
34 constexpr T get_min() {
35 static_assert(
37 "this type was not implemented in shambase::details::numeric_limits");
39 }
40
41 template<class T>
42 constexpr T get_epsilon() {
43 static_assert(
45 "this type was not implemented in shambase::details::numeric_limits");
46 static_assert(
47 primitive_type_info<T>::is_float, "this function can only be called on floats");
49 }
50
51 template<class T>
52 constexpr T get_infty() {
53 static_assert(
55 "this type was not implemented in shambase::details::numeric_limits");
56 static_assert(
57 primitive_type_info<T>::is_float, "this function can only be called on floats");
59 }
60
61} // namespace shambase
62
63#ifndef INT_ALIAS_LIM_DEFINED
64
69
74
79
84
85#endif
std::int8_t i8
8 bit integer
std::uint8_t u8
8 bit unsigned integer
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
std::uint16_t u16
16 bit unsigned integer
std::int16_t i16
16 bit integer
std::int64_t i64
64 bit integer
std::int32_t i32
32 bit integer
namespace for basic c++ utilities
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
constexpr i8 i8_max
i8 max value
constexpr u16 u16_max
u16 max value
constexpr u8 u8_min
u8 min value
constexpr u64 u64_max
u64 max value
constexpr u32 u32_max
u32 max value
constexpr u8 u8_max
u8 max value
constexpr i32 i32_max
i32 max value
constexpr i8 i8_min
i8 min value
constexpr u16 u16_min
u16 min value
constexpr i64 i64_min
i64 min value
constexpr i32 i32_min
i32 min value
constexpr i16 i16_min
i16 min value
constexpr i64 i64_max
i64 max value
constexpr u64 u64_min
u64 min value
constexpr i16 i16_max
i16 max value
constexpr u32 u32_min
u32 min value
static constexpr T infty
Infinity if the type can represent it.
static constexpr bool is_float
Whether the type is a float type.
static constexpr T min
The minimum value of the type (negative if float)
static constexpr T epsilon
The smallest value of the type that can be represented exactly.
static constexpr bool is_specialized
Whether the type is a specialized primitive type (i.e. not a float)
static constexpr T max
The maximum value of the type.