diff --git a/CMakeLists.txt b/CMakeLists.txt index ea7ac98..13e1fee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,6 +88,7 @@ add_library(fennec STATIC include/fennec/math/detail/__vector_traits.h include/fennec/lang/lang.h include/fennec/lang/detail/__bits.h + include/fennec/lang/integer.h ) # add metaprogramming templates as a dependency and also force documentation to be generated when fennec is compiled diff --git a/PLANNING.md b/PLANNING.md index 653cb48..8730215 100644 --- a/PLANNING.md +++ b/PLANNING.md @@ -32,7 +32,7 @@ This file serves as a general planning document for engine structure, systems, p Implementations of core engine systems should strive to be `O(1)` in implementations, both in terms of runtime and memory performance. This is obviously not a realistic goal, -so rather than the entire engine striving to be `O(1)` we should more specifically look +so rather than the goal requiring the entire engine to be `O(1)`, we should more specifically look at achieving `O(1)` performance on hot paths. Functions should be highly verbose, and in debug mode any bugprone or erroneous behaviour should throw @@ -98,7 +98,7 @@ All containers of the [C++ Standard Library](https://cppreference.com/w/cpp/cont Here are essential data-structures not specified in the C++ stdlib: - Graph → AI `graph` - Necessary for 2D and 3D navigation. - - Rooted Directed Tree `rd_tree` + - Rooted Directed Tree → Scene `rd_tree` - Defines the scene structure. @@ -165,6 +165,8 @@ fennec should be able to use Doxygen and LaTeX externally. Consider including bi This will be the core of the engine. - Event System + - Most events will fire at the start of the next tick, especially those related to physics and input. + - Events for graphics or audio should propagate immediately. - Core Engine Loop - System Manager - Ticks vs. Frames @@ -172,9 +174,6 @@ This will be the core of the engine. The following systems are not essential to the core engine, but are instead major systems that should be defined in their operation order: -**3D Systems will apply *before* their 2D Variants** - - ### Tick - **Update** - Events @@ -187,10 +186,10 @@ in their operation order: - Apply Velocities (Updates Position and Rotation) - Constraint Resolution - Collision Detection - - Collision Resolution (Adjust for Clipping) - - Soft Bodies resolve before Rigid Bodies + - Collision Resolution - Collision Response - - Calculate Forces + - Calculate Forces & Velocities + - Queue events for next tick ### Frame diff --git a/doxy/DoxyLayout.xml b/doxy/DoxyLayout.xml new file mode 100644 index 0000000..f87b016 --- /dev/null +++ b/doxy/DoxyLayout.xml @@ -0,0 +1,266 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/include/fennec/lang/bits.h b/include/fennec/lang/bits.h index e529e2b..ca28fae 100644 --- a/include/fennec/lang/bits.h +++ b/include/fennec/lang/bits.h @@ -34,9 +34,11 @@ /// /// \page fennec_lang_bit_manipulation Bit Manipulation /// +/// \code #include \endcode +/// /// This header contains definitions for manipulating the bits of a provided object or pointer. /// -/// +///
///
Syntax /// Description /// diff --git a/include/fennec/lang/conditional_types.h b/include/fennec/lang/conditional_types.h index 67e7101..80cd310 100644 --- a/include/fennec/lang/conditional_types.h +++ b/include/fennec/lang/conditional_types.h @@ -35,21 +35,32 @@ /// /// \page fennec_lang_conditional_types Conditional Types /// -/// +/// \code #include \endcode +/// +/// This header contains various compile-time functions for conditionally setting types, detecting types, or +/// conditionally enabling functions.

+/// +///
///
Syntax /// Description /// ///

-/// \ref fennec::conditional "conditional::type"
+/// \ref fennec::conditional "typename conditional::type"
/// \ref fennec::conditional_t "conditional_t" ///
/// \copydetails fennec::conditional /// ///

-/// \ref fennec::detect "detect, ArgsT...>::type"
+/// \ref fennec::detect "typename detect, ArgsT...>::type"
/// \ref fennec::detect_t "detect_t, ArgsT...>" ///
/// \copydetails fennec::detect +/// +///

+/// \ref fennec::enable_if "typename enable_if::type"
+/// \ref fennec::enable_if_t "enable_if_t" +///
+/// \copydetails fennec::enable_if ///
/// /// @@ -126,9 +137,35 @@ struct detect using type = DetectT; static constexpr bool is_detected = true; +}; + // fennec::enable_if =================================================================================================== -}; + +/// +/// \brief Leverage SFINAE to conditionally enable a function or class at compile-time +/// +/// \details If `B` is `true`, define a public member type `type`. Otherwise, there is no member.
+/// **Example Usage** +/// \code{.cpp} +/// template, bool> = true> +/// TypeT conditional_func() { return 0; } +/// \endcode +/// +/// \tparam B A boolean value +/// \tparam T The type to conditionally define +template +struct enable_if {}; + +/// +/// \brief Shorthand for ```typename enable_if::type``` +template +using enable_if_t = typename enable_if::type; + +// true case +template +struct enable_if { using type = T; }; } diff --git a/include/fennec/lang/constants.h b/include/fennec/lang/constants.h index 36418d8..e6433c2 100644 --- a/include/fennec/lang/constants.h +++ b/include/fennec/lang/constants.h @@ -31,6 +31,37 @@ #ifndef FENNEC_LANG_CONSTANTS_H #define FENNEC_LANG_CONSTANTS_H +/// +/// +/// \page fennec_lang_constants Constants +/// +/// \brief This header is part of the metaprogramming library. It defines structures for constant values, +/// used during compile time. +/// +/// \code #include \endcode +/// +/// +///
Syntax +/// Description +/// +///

+/// \ref fennec::integral_constant "integral_constant::type"
+///
+/// \copydetails fennec::integral_constant +/// +///

+/// \ref fennec::bool_constant "bool_constant::type"
+///
+/// \copydetails fennec::bool_constant +/// +///

+/// \ref fennec::bool_constant "bool_constant::type"
+///
+/// \copydetails fennec::bool_constant +/// +///
+/// + #include namespace fennec @@ -39,19 +70,19 @@ namespace fennec /// /// \brief metaprogramming integral constant /// -/// \details -/// \tparam T type of the constant -/// \tparam V value of the constant -template struct integral_constant +/// \details A metaprogramming integral constant +/// \tparam IntT type of the constant +/// \tparam ValueV value of the constant +template struct integral_constant { /// /// \brief value of the constant - inline static constexpr T value = V; + inline static constexpr IntT value = ValueV; /// /// \brief cast operator to allow for braced initialization /// \returns the value of the constant - constexpr operator T() const noexcept { return V; } + constexpr operator IntT() const noexcept { return value; } }; @@ -59,10 +90,10 @@ template struct integral_constant /// \brief metaprogramming boolean constant /// /// \details -/// \tparam V value of the constant -template +/// \tparam ValueV value of the constant +template struct bool_constant - : integral_constant {}; + : integral_constant {}; /// diff --git a/include/fennec/lang/integer.h b/include/fennec/lang/integer.h new file mode 100644 index 0000000..e660af9 --- /dev/null +++ b/include/fennec/lang/integer.h @@ -0,0 +1,146 @@ +// ===================================================================================================================== +// fennec, a free and open source game engine +// Copyright © 2025 Medusa Slockbower +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// ===================================================================================================================== + +/// +/// \file integer.h +/// \brief metaprogramming integer type info +/// +/// +/// \details this file is automatically generated for the current build environment +/// +/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html)) +/// +/// + +#ifndef FENNEC_LANG_INTEGER_H +#define FENNEC_LANG_INTEGER_H + +#undef WCHAR_MIN +#undef WCHAR_MAX + +#define CHAR_IS_SIGNED true +#define CHAR_ROUNDS 0x0 +#define CHAR_RADIX_DIG 0x7 +#define CHAR_DIG 0x2 +#define CHAR_DECIMAL_DIG 0x0 +#define CHAR_RADIX 0x2 +#define CHAR_TRAPS 0xtrue +#define CHAR_MIN 0xffffff80 +#define CHAR_MAX 0x7f + +#define WCHAR_IS_SIGNED true +#define WCHAR_ROUNDS 0x0 +#define WCHAR_RADIX_DIG 0x1f +#define WCHAR_DIG 0x9 +#define WCHAR_DECIMAL_DIG 0x0 +#define WCHAR_RADIX 0x2 +#define WCHAR_TRAPS 0xtrue +#define WCHAR_MIN 0x80000000 +#define WCHAR_MAX 0x7fffffff + +#define SCHAR_ROUNDS 0x0 +#define SCHAR_RADIX_DIG 0x7 +#define SCHAR_DIG 0x2 +#define SCHAR_DECIMAL_DIG 0x0 +#define SCHAR_RADIX 0x2 +#define SCHAR_TRAPS 0xtrue +#define SCHAR_MIN 0xffffff80 +#define SCHAR_MAX 0x7f + +#define UCHAR_ROUNDS 0x0 +#define UCHAR_RADIX_DIG 0x8 +#define UCHAR_DIG 0x2 +#define UCHAR_DECIMAL_DIG 0x0 +#define UCHAR_RADIX 0x2 +#define UCHAR_TRAPS 0xtrue +#define UCHAR_MIN 0x0 +#define UCHAR_MAX 0xff + +#define SHORT_ROUNDS 0x0 +#define SHORT_RADIX_DIG 0xf +#define SHORT_DIG 0x4 +#define SHORT_DECIMAL_DIG 0x0 +#define SHORT_RADIX 0x2 +#define SHORT_TRAPS 0xtrue +#define SHORT_MIN 0x8000 +#define SHORT_MAX 0x7fff + +#define USHORT_ROUNDS 0x0 +#define USHORT_RADIX_DIG 0x10 +#define USHORT_DIG 0x4 +#define USHORT_DECIMAL_DIG 0x0 +#define USHORT_RADIX 0x2 +#define USHORT_TRAPS 0xtrue +#define USHORT_MIN 0x0 +#define USHORT_MAX 0xffff + +#define INT_ROUNDS 0x0 +#define INT_RADIX_DIG 0x1f +#define INT_DIG 0x9 +#define INT_DECIMAL_DIG 0x0 +#define INT_RADIX 0x2 +#define INT_TRAPS 0xtrue +#define INT_MIN 0x80000000 +#define INT_MAX 0x7fffffff + +#define UINT_ROUNDS 0x0 +#define UINT_RADIX_DIG 0x20 +#define UINT_DIG 0x9 +#define UINT_DECIMAL_DIG 0x0 +#define UINT_RADIX 0x2 +#define UINT_TRAPS 0xtrue +#define UINT_MIN 0x0 +#define UINT_MAX 0xffffffff + +#define LONG_ROUNDS 0x0 +#define LONG_RADIX_DIG 0x3f +#define LONG_DIG 0x12 +#define LONG_DECIMAL_DIG 0x0 +#define LONG_RADIX 0x2 +#define LONG_TRAPS 0xtrue +#define LONG_MIN 0x8000000000000000 +#define LONG_MAX 0x7fffffffffffffff + +#define ULONG_ROUNDS 0x0 +#define ULONG_RADIX_DIG 0x40 +#define ULONG_DIG 0x13 +#define ULONG_DECIMAL_DIG 0x0 +#define ULONG_RADIX 0x2 +#define ULONG_TRAPS 0xtrue +#define ULONG_MIN 0x0 +#define ULONG_MAX 0xffffffffffffffff + +#define LLONG_ROUNDS 0x0 +#define LLONG_RADIX_DIG 0x3f +#define LLONG_DIG 0x12 +#define LLONG_DECIMAL_DIG 0x0 +#define LLONG_RADIX 0x2 +#define LLONG_TRAPS 0xtrue +#define LLONG_MIN 0x8000000000000000 +#define LLONG_MAX 0x7fffffffffffffff + +#define ULLONG_ROUNDS 0x0 +#define ULLONG_RADIX_DIG 0x40 +#define ULLONG_DIG 0x13 +#define ULLONG_DECIMAL_DIG 0x0 +#define ULLONG_RADIX 0x2 +#define ULLONG_TRAPS 0xtrue +#define ULLONG_MIN 0x0 +#define ULLONG_MAX 0xffffffffffffffff + +#endif // FENNEC_LANG_INTEGER_H diff --git a/include/fennec/lang/intrinsics.h b/include/fennec/lang/intrinsics.h index 1c2377b..0c9af6f 100644 --- a/include/fennec/lang/intrinsics.h +++ b/include/fennec/lang/intrinsics.h @@ -16,10 +16,89 @@ // along with this program. If not, see . // ===================================================================================================================== +/// +/// \file intrinsics.h +/// \brief This header contains definitions for compiler intrinsics necessary for implementing functions of the +/// C++ stdlib. +/// +/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html)) +/// +/// #ifndef FENNEC_LANG_INTRINSICS_H #define FENNEC_LANG_INTRINSICS_H +/// +/// \page fennec_lang_intrinsics Intrinsics +/// +/// \brief This header contains definitions for compiler intrinsics necessary for implementing functions of the +/// C++ stdlib. +/// +/// +/// +///
Syntax +/// Description +/// +///

+/// `FENNEC_HAS_BUILTIN_BIT_CAST`
+/// `Y FENNEC_BUILTIN_BIT_CAST(X)` +///
+/// An intrinsic for doing a bitwise cast without using `reinterpret_cast`. +/// +///

+/// `FENNEC_HAS_BUILTIN_ADDRESSOF`
+/// `Y FENNEC_BUILTIN_ADDRESSOF(X)` +///
+/// Obtains the true address of an object in circumstances where `operator&` is overloaded. +/// +///

+/// `FENNEC_HAS_BUILTIN_IS_CONVERTIBLE`
+/// `B FENNEC_BUILTIN_IS_CONVERTIBLE(X, Y)` +///
+/// Checks if type `X` can be converted to type `Y`. +/// +///

+/// `FENNEC_HAS_BUILTIN_IS_EMPTY`
+/// `B FENNEC_BUILTIN_IS_EMPTY(X)` +///
+/// Checks if type `X` stores no data. +/// +///

+/// `FENNEC_HAS_BUILTIN_IS_POLYMORPHIC`
+/// `B FENNEC_BUILTIN_IS_POLYMORPHIC(X)` +///
+/// Checks if type `X` is polymorphic, this is for classes only thus checks only for subtyping +/// +///

+/// `FENNEC_HAS_BUILTIN_IS_FINAL`
+/// `B FENNEC_BUILTIN_IS_FINAL(X)` +///
+/// Checks if type `X` is final, meaning a function or class cannot be derived from. +/// +///

+/// `FENNEC_HAS_BUILTIN_IS_ABSTRACT`
+/// `B FENNEC_BUILTIN_IS_ABSTRACT(X)` +///
+/// Opposite of `FENNEC_BUILTIN_IS_FINAL`, checks if abstract, meaning `X` has at least one pure virtual function. +/// +///

+/// `FENNEC_HAS_BUILTIN_IS_STANDARD_LAYOUT`
+/// `B FENNEC_BUILTIN_IS_STANDARD_LAYOUT(X)` +///
+/// Checks if `X` has a standard layout, here is [full criteria](https://www.cppreference.com/w/cpp/language/classes.html#Standard-layout_class) +/// for this trait +/// +///

+/// `FENNEC_HAS_BUILTIN_IS_CONSTRUCTIBLE`
+/// `B FENNEC_BUILTIN_IS_CONSTRUCTIBLE(X, ...)` +///
+/// Checks if type `X` is constructible with args `...`, such that `X::X(...)` exists. +/// +///
+/// +/// + + // Most major compilers support __has_builtin, notably GCC, MINGW, CLANG, and MSVC #if defined(__has_builtin) @@ -45,10 +124,10 @@ // can_convert is also very difficult to implement without intrinsics #if __has_builtin(__is_convertible) -# define FENNEC_HAS_BUILTIN_CAN_CONVERT 1 -# define FENNEC_BUILTIN_CAN_CONVERT(arg0, arg1) __is_convertible(arg0, arg1) +# define FENNEC_HAS_BUILTIN_IS_CONVERTIBLE 1 +# define FENNEC_BUILTIN_IS_CONVERTIBLE(arg0, arg1) __is_convertible(arg0, arg1) #else -# define FENNEC_HAS_BUILTIN_CAN_CONVERT 0 +# define FENNEC_HAS_BUILTIN_IS_CONVERTIBLE 0 #endif // Inconsistent without intrinsics. diff --git a/include/fennec/lang/lang.h b/include/fennec/lang/lang.h index 49de51a..0c58a0a 100644 --- a/include/fennec/lang/lang.h +++ b/include/fennec/lang/lang.h @@ -37,7 +37,10 @@ /// This library implements the parts of the C++ stdlib that relate to built-in types and metaprogramming. /// /// - \subpage fennec_lang_bit_manipulation +/// - \subpage fennec_lang_intrinsics +/// - \subpage fennec_lang_limits /// - \subpage fennec_lang_metaprogramming +/// - \subpage fennec_lang_types /// /// @@ -45,11 +48,12 @@ /// \page fennec_lang_metaprogramming Metaprogramming /// /// Metaprogramming is a method of obtaining information about the structure of the code at compile time. -/// This includes getting traits of types, such as with \ref fennec::numeric_limits. You may even programmatically -/// enable functions based on the info of the types that the function uses. +/// This includes getting traits of types, such as with \ref fennec::numeric_limits. You may even +/// \ref fennec_lang_conditional_types "programmatically enable" functions based on the info of the types that the function uses. /// +/// - \subpage fennec_lang_constants /// - \subpage fennec_lang_conditional_types -/// +/// - \subpage fennec_lang_numeric_transforms /// /// diff --git a/include/fennec/lang/limits.h b/include/fennec/lang/limits.h index 9ca0a4a..f73836c 100644 --- a/include/fennec/lang/limits.h +++ b/include/fennec/lang/limits.h @@ -16,14 +16,198 @@ // along with this program. If not, see . // ===================================================================================================================== +/// +/// \file limits.h +/// \brief contains the limits of builtin data types to C++ +/// +/// +/// \details +/// \author Medusa Slockbower +/// +/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html)) +/// +/// + #ifndef FENNEC_LANG_LIMITS_H #define FENNEC_LANG_LIMITS_H +/// +/// \page fennec_lang_limits Limits +/// +/// \brief This header defines fennec::numeric_limits which contains info regarding the limits of numeric types including +/// floats and integers. There are overloads for all builtin types, and overloads for other types are included in +/// their own header. +/// +/// \code{.cpp}#include \endcode +/// +/// \section fennec_lang_limits_numeric_limits Numeric Limits +/// +///
Member +/// Description +/// +///
Traits +/// +///

+/// \ref fennec::numeric_limits::is_specialized "is_specialized" +///
+/// \copybrief fennec::numeric_limits::is_specialized +/// +///

+/// \ref fennec::numeric_limits::is_signed "is_signed" +///
+/// \copybrief fennec::numeric_limits::is_signed +/// +///

+/// \ref fennec::numeric_limits::is_integer "is_integer" +///
+/// \copybrief fennec::numeric_limits::is_integer +/// +///

+/// \ref fennec::numeric_limits::is_exact "is_exact" +///
+/// \copybrief fennec::numeric_limits::is_exact +/// +///

+/// \ref fennec::numeric_limits::has_infinity "has_infinity" +///
+/// \copybrief fennec::numeric_limits::has_infinity +/// +///

+/// \ref fennec::numeric_limits::has_quiet_nan "has_quiet_nan" +///
+/// \copybrief fennec::numeric_limits::has_quiet_nan +/// +///

+/// \ref fennec::numeric_limits::has_signaling_nan "has_signaling_nan" +///
+/// \copybrief fennec::numeric_limits::has_signaling_nan +/// +///

+/// \ref fennec::numeric_limits::is_iec559 "is_iec559" +///
+/// \copybrief fennec::numeric_limits::is_iec559 +/// +///

+/// \ref fennec::numeric_limits::is_bounded "is_bounded" +///
+/// \copybrief fennec::numeric_limits::is_bounded +/// +///

+/// \ref fennec::numeric_limits::is_modulo "is_modulo" +///
+/// \copybrief fennec::numeric_limits::is_modulo +/// +///

+/// \ref fennec::numeric_limits::tinyness_before "tinyness_before" +///
+/// \copybrief fennec::numeric_limits::tinyness_before +/// +///

+/// \ref fennec::numeric_limits::traps "traps" +///
+/// \copybrief fennec::numeric_limits::traps +/// +///
Binary +/// +///

+/// \ref fennec::numeric_limits::radix "radix" +///
+/// \copybrief fennec::numeric_limits::radix +/// +///

+/// \ref fennec::numeric_limits::digits "digits" +///
+/// \copybrief fennec::numeric_limits::digits +/// +///

+/// \ref fennec::numeric_limits::digits10 "digits10" +///
+/// \copybrief fennec::numeric_limits::digits10 +/// +///

+/// \ref fennec::numeric_limits::max_digits10 "max_digits10" +///
+/// \copybrief fennec::numeric_limits::max_digits10 +/// +///

+/// \ref fennec::numeric_limits::min_exponent "min_exponent" +///
+/// \copybrief fennec::numeric_limits::min_exponent +/// +///

+/// \ref fennec::numeric_limits::min_exponent10 "min_exponent10" +///
+/// \copybrief fennec::numeric_limits::min_exponent10 +/// +///

+/// \ref fennec::numeric_limits::max_exponent "max_exponent" +///
+/// \copybrief fennec::numeric_limits::max_exponent +/// +///

+/// \ref fennec::numeric_limits::max_exponent10 "max_exponent10" +///
+/// \copybrief fennec::numeric_limits::max_exponent10 +/// +///
Limits +/// +///

+/// \ref fennec::numeric_limits::min "min()" +///
+/// \copybrief fennec::numeric_limits::min +/// +///

+/// \ref fennec::numeric_limits::max "max()" +///
+/// \copybrief fennec::numeric_limits::max +/// +///

+/// \ref fennec::numeric_limits::lowest "lowest()" +///
+/// \copybrief fennec::numeric_limits::lowest +/// +///

+/// \ref fennec::numeric_limits::epsilon "epsilon()" +///
+/// \copybrief fennec::numeric_limits::epsilon +/// +///

+/// \ref fennec::numeric_limits::round_error "round_error()" +///
+/// \copybrief fennec::numeric_limits::round_error +/// +///

+/// \ref fennec::numeric_limits::infinity "infinity()" +///
+/// \copybrief fennec::numeric_limits::infinity +/// +///

+/// \ref fennec::numeric_limits::quiet_NaN "quiet_NaN()" +///
+/// \copybrief fennec::numeric_limits::quiet_NaN +/// +///

+/// \ref fennec::numeric_limits::signaling_NaN "signaling_NaN()" +///
+/// \copybrief fennec::numeric_limits::signaling_NaN +/// +///

+/// \ref fennec::numeric_limits::denorm_min "denorm_min()" +///
+/// \copybrief fennec::numeric_limits::denorm_min +/// +///
+/// +/// + #include + #include #include +#include +#include namespace fennec { @@ -51,6 +235,8 @@ template struct numeric_limits static constexpr bool has_infinity = false; ///< Check if TypeT can hold a value representing infinity static constexpr bool has_quiet_nan = false; ///< Check if TypeT can hold a non-signaling nan static constexpr bool has_signaling_nan = false; ///< Check if TypeT can hold a signaling nan + static constexpr bool has_denorm = false; ///< Check if TypeT denormalizes + static constexpr bool has_denorm_loss = false; ///< Check if TypeT has precision loss when denormalized static constexpr bool is_iec559 = false; ///< Check if a TypeT representing a float is IEC 559 or IEEE 754 static constexpr bool is_bounded = false; ///< Check if TypeT represents a finite set of values static constexpr bool is_modulo = false; ///< Check if TypeT can handle modulo arithmetic @@ -69,9 +255,9 @@ template struct numeric_limits static constexpr float_round_style rounding_style = round_indeterminate; ///< The rounding style of TypeT // This is very poorly named and defined in the C++ Standard so these functions differ - static constexpr TypeT min() { return TypeT(); } ///< The minimum finite value of TypeT - static constexpr TypeT max() { return TypeT(); } ///< The maximum finite value of TypeT - static constexpr TypeT lowest() { return TypeT(); } ///< The smallest positive value of TypeT + static constexpr TypeT min() { return TypeT(); } ///< Returns the minimum finite value of TypeT + static constexpr TypeT max() { return TypeT(); } ///< Returns the maximum finite value of TypeT + static constexpr TypeT lowest() { return TypeT(); } ///< Returns the smallest positive value of TypeT static constexpr TypeT epsilon() { return TypeT(); } ///< Returns the difference between 1.0 and the next representable value static constexpr TypeT round_error() { return TypeT(); } ///< Returns the max rounding error of TypeT static constexpr TypeT infinity() { return TypeT(); } ///< Returns a value of TypeT holding a positive infinity @@ -80,6 +266,8 @@ template struct numeric_limits static constexpr TypeT denorm_min() { return TypeT(); } ///< Returns a value of TypeT holding the smallest positive subnormal }; +// Overload definitions for basic types + // Overload for the builtin floating point type template<> struct numeric_limits { @@ -107,9 +295,9 @@ template<> struct numeric_limits static constexpr int max_exponent = FLT_MAX_EXP; static constexpr int max_exponent10 = FLT_MAX_10_EXP; - static constexpr double min() { return FLT_MIN; } + static constexpr double min() { return -FLT_MAX; } static constexpr double max() { return FLT_MAX; } - static constexpr double lowest() { return -FLT_MAX; } + static constexpr double lowest() { return FLT_MIN; } static constexpr double epsilon() { return FLT_EPSILON; } static constexpr double round_error() { return FLT_ROUND_ERR; } static constexpr double infinity() { return FLT_INF; } @@ -145,9 +333,9 @@ template<> struct numeric_limits static constexpr int max_exponent = DBL_MAX_EXP; static constexpr int max_exponent10 = DBL_MAX_10_EXP; - static constexpr double min() { return DBL_MIN; } + static constexpr double min() { return -DBL_MAX; } static constexpr double max() { return DBL_MAX; } - static constexpr double lowest() { return -DBL_MAX; } + static constexpr double lowest() { return DBL_MIN; } static constexpr double epsilon() { return DBL_EPSILON; } static constexpr double round_error() { return DBL_ROUND_ERR; } static constexpr double infinity() { return DBL_INF; } @@ -156,6 +344,424 @@ template<> struct numeric_limits static constexpr double denorm_min() { return DBL_DENORM_MIN; } }; +// Overload for the builtin char type +template<> struct numeric_limits +{ + static constexpr bool is_specialized = true; + static constexpr bool is_signed = CHAR_IS_SIGNED; + static constexpr bool is_integer = true; + static constexpr bool is_exact = true; + static constexpr bool has_infinity = false; + static constexpr bool has_quiet_nan = false; + static constexpr bool has_signaling_nan = false; + static constexpr bool has_denorm = false; + static constexpr bool has_denorm_loss = false; + static constexpr bool is_iec559 = false; + static constexpr bool is_bounded = true; + static constexpr bool is_modulo = true; + static constexpr bool tinyness_before = false; + static constexpr bool traps = true; + + static constexpr int digits = CHAR_RADIX_DIG; + static constexpr int digits10 = CHAR_DIG; + static constexpr int max_digits10 = CHAR_DECIMAL_DIG; + static constexpr int radix = CHAR_RADIX; + static constexpr int min_exponent = 0; + static constexpr int min_exponent10 = 0; + static constexpr int max_exponent = 0; + static constexpr int max_exponent10 = 0; + + static constexpr double min() { return CHAR_MIN; } + static constexpr double max() { return CHAR_MAX; } + static constexpr double lowest() { return 1; } + static constexpr double epsilon() { return 1; } + static constexpr double round_error() { return 0; } + static constexpr double infinity() { return 0; } + static constexpr double quiet_NaN() { return 0; } + static constexpr double signaling_NaN() { return 0; } + static constexpr double denorm_min() { return 0; } +}; + +// Overload for the builtin signed char type +template<> struct numeric_limits +{ + static constexpr bool is_specialized = true; + static constexpr bool is_signed = true; + static constexpr bool is_integer = true; + static constexpr bool is_exact = true; + static constexpr bool has_infinity = false; + static constexpr bool has_quiet_nan = false; + static constexpr bool has_signaling_nan = false; + static constexpr bool has_denorm = false; + static constexpr bool has_denorm_loss = false; + static constexpr bool is_iec559 = false; + static constexpr bool is_bounded = true; + static constexpr bool is_modulo = true; + static constexpr bool tinyness_before = false; + static constexpr bool traps = true; + + static constexpr int digits = SCHAR_RADIX_DIG; + static constexpr int digits10 = SCHAR_DIG; + static constexpr int max_digits10 = SCHAR_DECIMAL_DIG; + static constexpr int radix = SCHAR_RADIX; + static constexpr int min_exponent = 0; + static constexpr int min_exponent10 = 0; + static constexpr int max_exponent = 0; + static constexpr int max_exponent10 = 0; + + static constexpr double min() { return SCHAR_MIN; } + static constexpr double max() { return SCHAR_MAX; } + static constexpr double lowest() { return 1; } + static constexpr double epsilon() { return 1; } + static constexpr double round_error() { return 0; } + static constexpr double infinity() { return 0; } + static constexpr double quiet_NaN() { return 0; } + static constexpr double signaling_NaN() { return 0; } + static constexpr double denorm_min() { return 0; } +}; + +// Overload for the builtin signed char type +template<> struct numeric_limits +{ + static constexpr bool is_specialized = true; + static constexpr bool is_signed = false; + static constexpr bool is_integer = true; + static constexpr bool is_exact = true; + static constexpr bool has_infinity = false; + static constexpr bool has_quiet_nan = false; + static constexpr bool has_signaling_nan = false; + static constexpr bool has_denorm = false; + static constexpr bool has_denorm_loss = false; + static constexpr bool is_iec559 = false; + static constexpr bool is_bounded = true; + static constexpr bool is_modulo = true; + static constexpr bool tinyness_before = false; + static constexpr bool traps = true; + + static constexpr int digits = UCHAR_RADIX_DIG; + static constexpr int digits10 = UCHAR_DIG; + static constexpr int max_digits10 = UCHAR_DECIMAL_DIG; + static constexpr int radix = UCHAR_RADIX; + static constexpr int min_exponent = 0; + static constexpr int min_exponent10 = 0; + static constexpr int max_exponent = 0; + static constexpr int max_exponent10 = 0; + + static constexpr double min() { return UCHAR_MIN; } + static constexpr double max() { return UCHAR_MAX; } + static constexpr double lowest() { return 1; } + static constexpr double epsilon() { return 1; } + static constexpr double round_error() { return 0; } + static constexpr double infinity() { return 0; } + static constexpr double quiet_NaN() { return 0; } + static constexpr double signaling_NaN() { return 0; } + static constexpr double denorm_min() { return 0; } +}; + +// Overload for the builtin signed char type +template<> struct numeric_limits +{ + static constexpr bool is_specialized = true; + static constexpr bool is_signed = true; + static constexpr bool is_integer = true; + static constexpr bool is_exact = true; + static constexpr bool has_infinity = false; + static constexpr bool has_quiet_nan = false; + static constexpr bool has_signaling_nan = false; + static constexpr bool has_denorm = false; + static constexpr bool has_denorm_loss = false; + static constexpr bool is_iec559 = false; + static constexpr bool is_bounded = true; + static constexpr bool is_modulo = true; + static constexpr bool tinyness_before = false; + static constexpr bool traps = true; + + static constexpr int digits = SHORT_RADIX_DIG; + static constexpr int digits10 = SHORT_DIG; + static constexpr int max_digits10 = SHORT_DECIMAL_DIG; + static constexpr int radix = SHORT_RADIX; + static constexpr int min_exponent = 0; + static constexpr int min_exponent10 = 0; + static constexpr int max_exponent = 0; + static constexpr int max_exponent10 = 0; + + static constexpr double min() { return SHORT_MIN; } + static constexpr double max() { return SHORT_MAX; } + static constexpr double lowest() { return 1; } + static constexpr double epsilon() { return 1; } + static constexpr double round_error() { return 0; } + static constexpr double infinity() { return 0; } + static constexpr double quiet_NaN() { return 0; } + static constexpr double signaling_NaN() { return 0; } + static constexpr double denorm_min() { return 0; } +}; + +// Overload for the builtin signed char type +template<> struct numeric_limits +{ + static constexpr bool is_specialized = true; + static constexpr bool is_signed = false; + static constexpr bool is_integer = true; + static constexpr bool is_exact = true; + static constexpr bool has_infinity = false; + static constexpr bool has_quiet_nan = false; + static constexpr bool has_signaling_nan = false; + static constexpr bool has_denorm = false; + static constexpr bool has_denorm_loss = false; + static constexpr bool is_iec559 = false; + static constexpr bool is_bounded = true; + static constexpr bool is_modulo = true; + static constexpr bool tinyness_before = false; + static constexpr bool traps = true; + + static constexpr int digits = USHORT_RADIX_DIG; + static constexpr int digits10 = USHORT_DIG; + static constexpr int max_digits10 = USHORT_DECIMAL_DIG; + static constexpr int radix = USHORT_RADIX; + static constexpr int min_exponent = 0; + static constexpr int min_exponent10 = 0; + static constexpr int max_exponent = 0; + static constexpr int max_exponent10 = 0; + + static constexpr double min() { return USHORT_MIN; } + static constexpr double max() { return USHORT_MAX; } + static constexpr double lowest() { return 1; } + static constexpr double epsilon() { return 1; } + static constexpr double round_error() { return 0; } + static constexpr double infinity() { return 0; } + static constexpr double quiet_NaN() { return 0; } + static constexpr double signaling_NaN() { return 0; } + static constexpr double denorm_min() { return 0; } +}; + +// Overload for the builtin signed char type +template<> struct numeric_limits +{ + static constexpr bool is_specialized = true; + static constexpr bool is_signed = true; + static constexpr bool is_integer = true; + static constexpr bool is_exact = true; + static constexpr bool has_infinity = false; + static constexpr bool has_quiet_nan = false; + static constexpr bool has_signaling_nan = false; + static constexpr bool has_denorm = false; + static constexpr bool has_denorm_loss = false; + static constexpr bool is_iec559 = false; + static constexpr bool is_bounded = true; + static constexpr bool is_modulo = true; + static constexpr bool tinyness_before = false; + static constexpr bool traps = true; + + static constexpr int digits = INT_RADIX_DIG; + static constexpr int digits10 = INT_DIG; + static constexpr int max_digits10 = INT_DECIMAL_DIG; + static constexpr int radix = INT_RADIX; + static constexpr int min_exponent = 0; + static constexpr int min_exponent10 = 0; + static constexpr int max_exponent = 0; + static constexpr int max_exponent10 = 0; + + static constexpr double min() { return INT_MIN; } + static constexpr double max() { return INT_MAX; } + static constexpr double lowest() { return 1; } + static constexpr double epsilon() { return 1; } + static constexpr double round_error() { return 0; } + static constexpr double infinity() { return 0; } + static constexpr double quiet_NaN() { return 0; } + static constexpr double signaling_NaN() { return 0; } + static constexpr double denorm_min() { return 0; } +}; + +// Overload for the builtin signed char type +template<> struct numeric_limits +{ + static constexpr bool is_specialized = true; + static constexpr bool is_signed = false; + static constexpr bool is_integer = true; + static constexpr bool is_exact = true; + static constexpr bool has_infinity = false; + static constexpr bool has_quiet_nan = false; + static constexpr bool has_signaling_nan = false; + static constexpr bool has_denorm = false; + static constexpr bool has_denorm_loss = false; + static constexpr bool is_iec559 = false; + static constexpr bool is_bounded = true; + static constexpr bool is_modulo = true; + static constexpr bool tinyness_before = false; + static constexpr bool traps = true; + + static constexpr int digits = UINT_RADIX_DIG; + static constexpr int digits10 = UINT_DIG; + static constexpr int max_digits10 = UINT_DECIMAL_DIG; + static constexpr int radix = UINT_RADIX; + static constexpr int min_exponent = 0; + static constexpr int min_exponent10 = 0; + static constexpr int max_exponent = 0; + static constexpr int max_exponent10 = 0; + + static constexpr double min() { return UINT_MIN; } + static constexpr double max() { return UINT_MAX; } + static constexpr double lowest() { return 1; } + static constexpr double epsilon() { return 1; } + static constexpr double round_error() { return 0; } + static constexpr double infinity() { return 0; } + static constexpr double quiet_NaN() { return 0; } + static constexpr double signaling_NaN() { return 0; } + static constexpr double denorm_min() { return 0; } +}; + +// Overload for the builtin signed char type +template<> struct numeric_limits +{ + static constexpr bool is_specialized = true; + static constexpr bool is_signed = true; + static constexpr bool is_integer = true; + static constexpr bool is_exact = true; + static constexpr bool has_infinity = false; + static constexpr bool has_quiet_nan = false; + static constexpr bool has_signaling_nan = false; + static constexpr bool has_denorm = false; + static constexpr bool has_denorm_loss = false; + static constexpr bool is_iec559 = false; + static constexpr bool is_bounded = true; + static constexpr bool is_modulo = true; + static constexpr bool tinyness_before = false; + static constexpr bool traps = true; + + static constexpr int digits = LONG_RADIX_DIG; + static constexpr int digits10 = LONG_DIG; + static constexpr int max_digits10 = LONG_DECIMAL_DIG; + static constexpr int radix = LONG_RADIX; + static constexpr int min_exponent = 0; + static constexpr int min_exponent10 = 0; + static constexpr int max_exponent = 0; + static constexpr int max_exponent10 = 0; + + static constexpr double min() { return LONG_MIN; } + static constexpr double max() { return LONG_MAX; } + static constexpr double lowest() { return 1; } + static constexpr double epsilon() { return 1; } + static constexpr double round_error() { return 0; } + static constexpr double infinity() { return 0; } + static constexpr double quiet_NaN() { return 0; } + static constexpr double signaling_NaN() { return 0; } + static constexpr double denorm_min() { return 0; } +}; + +// Overload for the builtin signed char type +template<> struct numeric_limits +{ + static constexpr bool is_specialized = true; + static constexpr bool is_signed = false; + static constexpr bool is_integer = true; + static constexpr bool is_exact = true; + static constexpr bool has_infinity = false; + static constexpr bool has_quiet_nan = false; + static constexpr bool has_signaling_nan = false; + static constexpr bool has_denorm = false; + static constexpr bool has_denorm_loss = false; + static constexpr bool is_iec559 = false; + static constexpr bool is_bounded = true; + static constexpr bool is_modulo = true; + static constexpr bool tinyness_before = false; + static constexpr bool traps = true; + + static constexpr int digits = ULONG_RADIX_DIG; + static constexpr int digits10 = ULONG_DIG; + static constexpr int max_digits10 = ULONG_DECIMAL_DIG; + static constexpr int radix = ULONG_RADIX; + static constexpr int min_exponent = 0; + static constexpr int min_exponent10 = 0; + static constexpr int max_exponent = 0; + static constexpr int max_exponent10 = 0; + + static constexpr double min() { return ULONG_MIN; } + static constexpr double max() { return ULONG_MAX; } + static constexpr double lowest() { return 1; } + static constexpr double epsilon() { return 1; } + static constexpr double round_error() { return 0; } + static constexpr double infinity() { return 0; } + static constexpr double quiet_NaN() { return 0; } + static constexpr double signaling_NaN() { return 0; } + static constexpr double denorm_min() { return 0; } +}; + +// Overload for the builtin signed char type +template<> struct numeric_limits +{ + static constexpr bool is_specialized = true; + static constexpr bool is_signed = true; + static constexpr bool is_integer = true; + static constexpr bool is_exact = true; + static constexpr bool has_infinity = false; + static constexpr bool has_quiet_nan = false; + static constexpr bool has_signaling_nan = false; + static constexpr bool has_denorm = false; + static constexpr bool has_denorm_loss = false; + static constexpr bool is_iec559 = false; + static constexpr bool is_bounded = true; + static constexpr bool is_modulo = true; + static constexpr bool tinyness_before = false; + static constexpr bool traps = true; + + static constexpr int digits = LLONG_RADIX_DIG; + static constexpr int digits10 = LLONG_DIG; + static constexpr int max_digits10 = LLONG_DECIMAL_DIG; + static constexpr int radix = LLONG_RADIX; + static constexpr int min_exponent = 0; + static constexpr int min_exponent10 = 0; + static constexpr int max_exponent = 0; + static constexpr int max_exponent10 = 0; + + static constexpr double min() { return LLONG_MIN; } + static constexpr double max() { return LLONG_MAX; } + static constexpr double lowest() { return 1; } + static constexpr double epsilon() { return 1; } + static constexpr double round_error() { return 0; } + static constexpr double infinity() { return 0; } + static constexpr double quiet_NaN() { return 0; } + static constexpr double signaling_NaN() { return 0; } + static constexpr double denorm_min() { return 0; } +}; + +// Overload for the builtin signed char type +template<> struct numeric_limits +{ + static constexpr bool is_specialized = true; + static constexpr bool is_signed = false; + static constexpr bool is_integer = true; + static constexpr bool is_exact = true; + static constexpr bool has_infinity = false; + static constexpr bool has_quiet_nan = false; + static constexpr bool has_signaling_nan = false; + static constexpr bool has_denorm = false; + static constexpr bool has_denorm_loss = false; + static constexpr bool is_iec559 = false; + static constexpr bool is_bounded = true; + static constexpr bool is_modulo = true; + static constexpr bool tinyness_before = false; + static constexpr bool traps = true; + + static constexpr int digits = ULLONG_RADIX_DIG; + static constexpr int digits10 = ULLONG_DIG; + static constexpr int max_digits10 = ULLONG_DECIMAL_DIG; + static constexpr int radix = ULLONG_RADIX; + static constexpr int min_exponent = 0; + static constexpr int min_exponent10 = 0; + static constexpr int max_exponent = 0; + static constexpr int max_exponent10 = 0; + + static constexpr double min() { return ULLONG_MIN; } + static constexpr double max() { return ULLONG_MAX; } + static constexpr double lowest() { return 1; } + static constexpr double epsilon() { return 1; } + static constexpr double round_error() { return 0; } + static constexpr double infinity() { return 0; } + static constexpr double quiet_NaN() { return 0; } + static constexpr double signaling_NaN() { return 0; } + static constexpr double denorm_min() { return 0; } +}; + } #endif // FENNEC_LANG_LIMITS_H diff --git a/include/fennec/lang/numeric_transforms.h b/include/fennec/lang/numeric_transforms.h index 9d9743b..3fa1ebf 100644 --- a/include/fennec/lang/numeric_transforms.h +++ b/include/fennec/lang/numeric_transforms.h @@ -30,6 +30,31 @@ #ifndef FENNEC_LANG_NUMERIC_TRANSFORMS_H #define FENNEC_LANG_NUMERIC_TRANSFORMS_H +/// +/// \page fennec_lang_numeric_transforms Numeric Transforms +/// +/// \code #include \endcode +/// +/// This header contains various compile-time functions for changing the characteristics of a provided type +/// +/// +///
Syntax +/// Description +/// +///

+/// \ref fennec::make_signed "typename make_signed::type"
+/// \ref fennec::make_signed_t "make_signed_t" +///
+/// \copydetails fennec::make_signed +/// +///

+/// \ref fennec::make_unsigned "typename make_unsigned::type"
+/// \ref fennec::make_unsigned_t "make_unsigned_t" +///
+/// \copydetails fennec::make_unsigned +/// +///
+ #include #include @@ -41,12 +66,20 @@ namespace fennec /// \tparam TypeT the integral type to transform template struct make_signed : detail::__make_signed> {}; +/// +/// \brief Shorthand for `typename make_signed::type` +template using make_signed_t = typename make_signed::type; + /// /// \brief Get the corresponding unsigned integral type of TypeT /// \tparam TypeT the integral type to transform template struct make_unsigned : detail::__make_unsigned> {}; +/// +/// \brief Shorthand for `typename make_unsigned::type` +template using make_unsigned_t = typename make_unsigned::type; + } #endif // FENNEC_LANG_NUMERIC_TRANSFORMS_H diff --git a/include/fennec/lang/type_traits.h b/include/fennec/lang/type_traits.h index f7b175d..28ed62c 100644 --- a/include/fennec/lang/type_traits.h +++ b/include/fennec/lang/type_traits.h @@ -198,7 +198,7 @@ template constexpr bool_t is_same_v /// \tparam T0 First type /// \tparam T1 Second type template struct can_convert - : bool_constant {}; + : bool_constant {}; /// /// \brief shorthand diff --git a/include/fennec/lang/type_transforms.h b/include/fennec/lang/type_transforms.h index bd13359..fca11af 100644 --- a/include/fennec/lang/type_transforms.h +++ b/include/fennec/lang/type_transforms.h @@ -55,24 +55,21 @@ template struct type_transform { // Pointer Conversions ================================================================================================= /// -/// \struct fennec::add_pointer /// \brief adds a pointer level to \p T /// -/// \details adds a pointer to the provided type such that ```T``` becomes ```T*``` +/// \details adds a pointer to the provided type such that `T` becomes `T*` /// \tparam T Resultant Type template struct add_pointer : type_transform{}; /// -/// \typedef fennec::add_pointer_t -/// \brief shorthand for ```typename add_pointer::type``` +/// \brief shorthand for `typename add_pointer::type` template using add_pointer_t = typename add_pointer::type; /// -/// \struct fennec::remove_pointer /// \brief removes a pointer level from \p T /// -/// \details removes a pointer from the provided type such that ```T*``` becomes ```T``` +/// \details removes a pointer from the provided type such that `T*` becomes `T` /// \tparam T Resultant Type template struct remove_pointer : type_transform {}; @@ -80,8 +77,7 @@ template struct remove_pointer : type_transform {}; template struct remove_pointer : type_transform {}; /// -/// \typedef fennec::remove_pointer_t -/// \brief shorthand for ```typename remove_pointer::type``` +/// \brief shorthand for `typename remove_pointer::type` template using remove_pointer_t = typename remove_pointer::type; @@ -89,36 +85,32 @@ template using remove_pointer_t = typename remove_pointer::type; // Reference Conversions =============================================================================================== /// -/// \struct fennec::add_reference /// \brief add a reference to \p T /// -/// \details adds a pointer to the provided type such that ```T``` becomes ```T&``` +/// \details adds a pointer to the provided type such that `T` becomes `T&` /// \tparam T Resultant Type template struct add_reference : type_transform {}; /// -/// \typedef fennec::add_reference_t -/// \brief shorthand for ```typename add_reference::type``` +/// \brief shorthand for `typename add_reference::type` template using add_reference_t = typename add_reference::type; /// -/// \struct fennec::remove_reference /// \brief remove a reference from \p T /// -/// \details removes references from the provided type such that ```T&``` and ```T&&``` become ```T``` +/// \details removes references from the provided type such that `T&` and `T&&` become `T` /// \tparam T Reference Type template struct remove_reference : type_transform {}; -// specialization for ```T&``` +// specialization for `T&` template struct remove_reference : type_transform {}; -// specialization for ```T&&``` +// specialization for `T&&` template struct remove_reference : type_transform {}; /// -/// \typedef fennec::remove_reference_t -/// \brief shorthand for ```typename remove_reference::type``` +/// \brief shorthand for `typename remove_reference::type` template using remove_reference_t = typename remove_reference::type; @@ -126,16 +118,14 @@ template using remove_reference_t = typename remove_reference::t // Const & Volatile Conversions ======================================================================================== /// -/// \struct fennec::add_const /// \brief add the const qualifier to the provided type \p T /// -/// \details adds const qualification to the provided type such that ```T``` becomes ```const T``` +/// \details adds const qualification to the provided type such that `T` becomes `const T` /// \tparam T Reference Type template struct add_const : type_transform {}; /// -/// \typedef fennec::add_const_t -/// \brief shorthand for ```typename add_const::type``` +/// \brief shorthand for `typename add_const::type` template using add_const_t = typename add_const::type; // specialization for const types @@ -143,16 +133,14 @@ template struct add_const : type_transform {}; /// -/// \struct fennec::remove_const /// \brief remove the const qualifier from the provided type \p T /// -/// \details removes const qualification from the provided type such that ```const T``` becomes ```T``` +/// \details removes const qualification from the provided type such that `const T` becomes `T` /// \tparam T Reference Type template struct remove_const : type_transform {}; /// -/// \typedef fennec::remove_const_t -/// \brief shorthand for ```typename remove_const::type``` +/// \brief shorthand for `typename remove_const::type` template using remove_const_t = typename remove_const::type; // specialization for const types @@ -161,16 +149,14 @@ template struct remove_const : type_transform {}; /// -/// \struct fennec::add_volatile /// \brief add the volatile qualifier to the provided type \p T /// -/// \details removes references from the provided type such that ```T``` becomes ```volatile T``` +/// \details removes references from the provided type such that `T` becomes `volatile T` /// \tparam T Reference Type template struct add_volatile : type_transform {}; /// -/// \typedef fennec::add_volatile_t -/// \brief shorthand for ```typename add_volatile::type``` +/// \brief shorthand for `typename add_volatile::type` template using add_volatile_t = typename add_volatile::type; // specialization for volatile types @@ -178,16 +164,14 @@ template struct add_volatile : type_transform struct remove_volatile : type_transform {}; /// -/// \typedef fennec::remove_volatile_t -/// \brief shorthand for ```typename remove_volatile::type``` +/// \brief shorthand for `typename remove_volatile::type` template using remove_volatile_t = typename remove_volatile::type; // specialization for volatile types @@ -196,17 +180,15 @@ template struct remove_volatile : type_transform {}; /// -/// \struct fennec::add_cv /// \brief remove the volatile qualifier from the provided type \p T /// -/// \details removes references from the provided type such that ```T```, ```const T```, and ```volatile T``` become -/// ```const volatile T``` +/// \details removes references from the provided type such that `T`, `const T`, and `volatile T` become +/// `const volatile T` /// \tparam T Reference Type template struct add_cv : type_transform {}; /// -/// \typedef fennec::add_cv_t -/// \brief shorthand for ```typename add_cv::type``` +/// \brief shorthand for `typename add_cv::type` template using add_cv_t = typename add_cv::type; // specialization for const types @@ -220,12 +202,11 @@ template struct add_cv : type_transform struct remove_cv : type_transform {}; @@ -239,12 +220,11 @@ template struct remove_cv : type_transform {}; template struct remove_cv : type_transform {}; /// -/// \brief shorthand for ```typename remove_cv::type``` +/// \brief shorthand for `typename remove_cv::type` template using remove_cv_t = typename remove_cv::type; -/// /// /// \brief add a reference and the const volatile qualifiers from the provided type \p T /// @@ -253,12 +233,11 @@ template using remove_cv_t = typename remove_cv::type; template struct add_cvr : type_transform>> {}; /// -/// \brief shorthand for ```typename add_cvr::type``` +/// \brief shorthand for `typename add_cvr::type` template using add_cvr_t = typename add_cvr::type; -/// /// /// \brief removes references as well as the const and volatile qualifiers from the provided type \p T /// @@ -268,7 +247,7 @@ template struct remove_cvr : type_transform::type``` +/// \brief shorthand for `typename remove_cvr::type` template using remove_cvr_t = typename remove_cvr::type; } diff --git a/include/fennec/lang/types.h b/include/fennec/lang/types.h index c78d8a1..9895724 100644 --- a/include/fennec/lang/types.h +++ b/include/fennec/lang/types.h @@ -31,6 +31,190 @@ #ifndef FENNEC_LANG_TYPES_H #define FENNEC_LANG_TYPES_H +/// +/// \page fennec_lang_types Types +/// +/// \brief This header contains definitions for built-in types. +/// +/// +///
Member +/// Description +/// +///
Basic Types +/// +///

+/// \ref fennec::bool_t "bool_t" +///
+/// \copybrief fennec::bool_t +/// +///

+/// \ref fennec::char_t "char_t" +///
+/// \copybrief fennec::char_t +/// +///

+/// \ref fennec::schar_t "schar_t" +///
+/// \copybrief fennec::schar_t +/// +///

+/// \ref fennec::uchar_t "uchar_t" +///
+/// \copybrief fennec::uchar_t +/// +///

+/// \ref fennec::short_t "short_t" +///
+/// \copybrief fennec::short_t +/// +///

+/// \ref fennec::ushort_t "ushort_t" +///
+/// \copybrief fennec::ushort_t +/// +///

+/// \ref fennec::int_t "int_t" +///
+/// \copybrief fennec::int_t +/// +///

+/// \ref fennec::uint_t "uint_t" +///
+/// \copybrief fennec::uint_t +/// +///

+/// \ref fennec::long_t "long_t" +///
+/// \copybrief fennec::long_t +/// +///

+/// \ref fennec::ulong_t "ulong_t" +///
+/// \copybrief fennec::ulong_t +/// +///

+/// \ref fennec::llong_t "llong_t" +///
+/// \copybrief fennec::llong_t +/// +///

+/// \ref fennec::ullong_t "ullong_t" +///
+/// \copybrief fennec::ullong_t +/// +///

+/// \ref fennec::float_t "float_t" +///
+/// \copybrief fennec::float_t +/// +///

+/// \ref fennec::double_t "double_t" +///
+/// \copybrief fennec::double_t +/// +///
Sized Arithmetic Types +/// +///

+/// \ref fennec::int8_t "int8_t" +///
+/// \copybrief fennec::int8_t +/// +///

+/// \ref fennec::int16_t "int16_t" +///
+/// \copybrief fennec::int16_t +/// +///

+/// \ref fennec::int32_t "int32_t" +///
+/// \copybrief fennec::int32_t +/// +///

+/// \ref fennec::int64_t "int64_t" +///
+/// \copybrief fennec::int64_t +/// +/// +///

+/// \ref fennec::uint8_t "uint8_t" +///
+/// \copybrief fennec::uint8_t +/// +///

+/// \ref fennec::uint16_t "uint16_t" +///
+/// \copybrief fennec::uint16_t +/// +///

+/// \ref fennec::uint32_t "uint32_t" +///
+/// \copybrief fennec::uint32_t +/// +///

+/// \ref fennec::uint64_t "uint64_t" +///
+/// \copybrief fennec::int64_t +/// +/// +///

+/// \ref fennec::float32_t "float32_t" +///
+/// \copybrief fennec::float32_t +/// +///

+/// \ref fennec::float64_t "float64_t" +///
+/// \copybrief fennec::float64_t +/// +/// +///
Special Types +/// +/// +///

+/// \ref fennec::nullptr_t "nullptr_t" +///
+/// \copybrief fennec::nullptr_t +/// +///

+/// \ref fennec::intptr_t "intptr_t" +///
+/// \copybrief fennec::intptr_t +/// +///

+/// \ref fennec::uintptr_t "uintptr_t" +///
+/// \copybrief fennec::uintptr_t +/// +///

+/// \ref fennec::intmax_t "intmax_t" +///
+/// \copybrief fennec::intmax_t +/// +///

+/// \ref fennec::uintmax_t "uintmax_t" +///
+/// \copybrief fennec::uintmax_t +/// +///

+/// \ref fennec::size_t "size_t" +///
+/// \copybrief fennec::size_t +/// +///

+/// \ref fennec::ptrdiff_t "ptrdiff_t" +///
+/// \copybrief fennec::ptrdiff_t +/// +///

+/// \ref fennec::void_t "void_t" +///
+/// \copybrief fennec::void_t +/// +/// +///
+/// +/// + #include namespace fennec diff --git a/include/fennec/math/common.h b/include/fennec/math/common.h index a10a1c0..19daa1b 100644 --- a/include/fennec/math/common.h +++ b/include/fennec/math/common.h @@ -40,6 +40,8 @@ /// /// \brief The Common Functions defined in the [OpenGL 4.6 Shading Language Specification](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.pdf). /// +/// \code #include \endcode +/// /// /// /// \section section_sign_functions Sign diff --git a/include/fennec/math/exponential.h b/include/fennec/math/exponential.h index 5fc7357..1e2d882 100644 --- a/include/fennec/math/exponential.h +++ b/include/fennec/math/exponential.h @@ -41,10 +41,12 @@ /// /// \brief The Exponential Functions defined in the [OpenGL 4.6 Shading Language Specification](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.pdf). /// +/// \code #include \endcode +/// /// /// \section Exponential Functions /// -/// +///
///
Syntax /// Description /// diff --git a/include/fennec/math/geometric.h b/include/fennec/math/geometric.h index 1f6060c..a9b250c 100644 --- a/include/fennec/math/geometric.h +++ b/include/fennec/math/geometric.h @@ -43,6 +43,8 @@ /// /// \brief The Geometric Functions defined in the [OpenGL 4.6 Shading Language Specification](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.pdf). /// +/// \code #include \endcode +/// /// /// \section Geometric Functions /// diff --git a/include/fennec/math/math.h b/include/fennec/math/math.h index 153f87d..6722664 100644 --- a/include/fennec/math/math.h +++ b/include/fennec/math/math.h @@ -41,18 +41,26 @@ /// /// \page fennec_math Math Library /// +/// \brief The fennec Math Library. +/// Includes various types and functions related to mathematics, predominantly linear algebra. +/// +/// \code #include \endcode +/// /// The \ref fennec Math Library is composed of the modules listed in below. /// The overarching goal of this math library is to implement the math types and functions of the /// [OpenGL 4.6 Shading Language Specification](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.pdf). /// +/// The data types are influenced by the GLM and CxxSwizzle implementations. The resulting structures were optimized +/// to decrease compilation times and allow the compiler to more easily optimize the resulting binary code. +/// /// - \subpage fennec_math_topics "Topics" /// - \ref fennec_math_set_theory +/// - \ref fennec_math_swizzle /// - \subpage fennec_math_data_types "Data Types" /// - \ref fennec_math_scalar /// - \ref fennec_math_vector /// - \ref fennec_math_matrix /// - \subpage fennec_math_functions "Functions" -/// - \ref fennec_math_set_theory /// - \ref fennec_math_common /// - \ref fennec_math_exponential /// - \ref fennec_math_geometric @@ -64,6 +72,7 @@ /// /// \page fennec_math_topics Topics /// - \subpage fennec_math_set_theory +/// - \subpage fennec_math_swizzle /// /// @@ -75,7 +84,6 @@ /// /// \page fennec_math_functions Functions -/// - \subpage fennec_math_set_theory /// - \subpage fennec_math_common /// - \subpage fennec_math_exponential /// - \subpage fennec_math_geometric @@ -88,9 +96,9 @@ /// /// \page fennec_math_set_theory Set Theory /// -/// Binary Mathematics, like most branches of Mathematics, is built, foundationally, upon Set Theory. Set Theory is -/// the branch of Mathematics that studies Sets. Sets contain a collection of elements which may be numbers, or other -/// mathematical values and structures. +/// Binary Mathematics, like most branches of Mathematics, is built upon Set Theory. Set Theory is +/// the branch of Mathematics that studies Sets. Sets contain a collection of elements which may be numbers, as well as other +/// mathematical structures, types, or values. /// /// Set definitions for all mathematical structures in the \ref fennec_math "Fennec Math Library" are present in /// their respective pages. diff --git a/include/fennec/math/matrix.h b/include/fennec/math/matrix.h index 1cd106a..40173cd 100644 --- a/include/fennec/math/matrix.h +++ b/include/fennec/math/matrix.h @@ -28,17 +28,20 @@ /// /// -/// +#ifndef FENNEC_MATH_MATRIX_H +#define FENNEC_MATH_MATRIX_H + /// /// /// \page fennec_math_matrix Matrices /// +/// \brief The fennec Matrix Math Module +/// +/// \code #include \endcode +/// /// /// /// - -#ifndef FENNEC_MATH_MATRIX_H -#define FENNEC_MATH_MATRIX_H #include diff --git a/include/fennec/math/relational.h b/include/fennec/math/relational.h index ca3da20..c5700bb 100644 --- a/include/fennec/math/relational.h +++ b/include/fennec/math/relational.h @@ -38,7 +38,9 @@ /// /// \brief The Relational Functions defined in the [OpenGL 4.6 Shading Language Specification](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.pdf). /// -/// +/// \code #include \endcode +/// +///
///
Syntax /// Description /// diff --git a/include/fennec/math/scalar.h b/include/fennec/math/scalar.h index af36966..29f8395 100644 --- a/include/fennec/math/scalar.h +++ b/include/fennec/math/scalar.h @@ -39,6 +39,10 @@ /// \page fennec_math_scalar Scalars /// \anchor scalar /// +/// \brief The base scalar types of the fennec Math Library +/// +/// \code #include \endcode +/// /// The \ref fennec Library considers any type that passes ```is_arithmetic``` to be a \ref scalar "Scalar." Bools are /// supported as a logical type. /// diff --git a/include/fennec/math/swizzle.h b/include/fennec/math/swizzle.h index d5dee7f..e307322 100644 --- a/include/fennec/math/swizzle.h +++ b/include/fennec/math/swizzle.h @@ -31,6 +31,16 @@ #ifndef FENNEC_MATH_SWIZZLE_H #define FENNEC_MATH_SWIZZLE_H +/// +/// +/// \page fennec_math_swizzle Swizzling +/// +/// \brief A submodule of the fennec Vector Math Module, used for "swizzling" vectors. +/// +/// \code #include \endcode +/// +/// + #include #include diff --git a/include/fennec/math/trigonometric.h b/include/fennec/math/trigonometric.h index 350a3d5..6e1206a 100644 --- a/include/fennec/math/trigonometric.h +++ b/include/fennec/math/trigonometric.h @@ -36,7 +36,9 @@ /// /// \page fennec_math_trigonometric Trigonometry /// -/// \brief The fennec Trigonometry Module +/// \brief The Trigonometric Functions defined in the [OpenGL 4.6 Shading Language Specification](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.pdf). +/// +/// \code #include \endcode /// /// /// @@ -62,7 +64,7 @@ /// /// \section section_fennec_trigonometric_functions Trigonometric Functions /// -/// +///
///
Syntax /// Description /// @@ -103,7 +105,7 @@ /// /// \section section_fennec_hyperbolic_functions Hyperbolic Functions /// -/// +///
///
Syntax /// Description /// diff --git a/include/fennec/math/vector.h b/include/fennec/math/vector.h index 0b8f3fe..04f1fd5 100644 --- a/include/fennec/math/vector.h +++ b/include/fennec/math/vector.h @@ -38,11 +38,12 @@ /// /// \brief The fennec Vector Math Module /// +/// \code #include \endcode +/// /// /// \section vector_types Types /// -/// -/// +///
///
Type Corresponding Type Brief ///
Floats ///
```vec2``` \ref fennec::vec2 \copybrief fennec::vec2 diff --git a/metaprogramming/CMakeLists.txt b/metaprogramming/CMakeLists.txt index aef9141..1722344 100644 --- a/metaprogramming/CMakeLists.txt +++ b/metaprogramming/CMakeLists.txt @@ -4,7 +4,8 @@ project(fennec-metaprogramming) set(CMAKE_CXX_STANDARD 26) add_executable(fennec-metaprogramming main.cpp - float.h) + float.h + integer.h) add_custom_command( OUTPUT .metaprogramming COMMAND fennec-metaprogramming diff --git a/metaprogramming/float.h b/metaprogramming/float.h index 61e784d..20cfa84 100644 --- a/metaprogramming/float.h +++ b/metaprogramming/float.h @@ -9,115 +9,115 @@ inline void float_h() { - std::ofstream flt("float.h"); + std::ofstream out("float.h"); - flt << "// =====================================================================================================================" << std::endl; - flt << "// fennec, a free and open source game engine" << std::endl; - flt << "// Copyright © 2025 Medusa Slockbower" << std::endl; - flt << "//" << std::endl; - flt << "// This program is free software: you can redistribute it and/or modify" << std::endl; - flt << "// it under the terms of the GNU General Public License as published by" << std::endl; - flt << "// the Free Software Foundation, either version 3 of the License, or" << std::endl; - flt << "// (at your option) any later version." << std::endl; - flt << "//" << std::endl; - flt << "// This program is distributed in the hope that it will be useful," << std::endl; - flt << "// but WITHOUT ANY WARRANTY; without even the implied warranty of" << std::endl; - flt << "// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" << std::endl; - flt << "// GNU General Public License for more details." << std::endl; - flt << "//" << std::endl; - flt << "// You should have received a copy of the GNU General Public License" << std::endl; - flt << "// along with this program. If not, see ." << std::endl; - flt << "// =====================================================================================================================" << std::endl; + out << "// =====================================================================================================================" << std::endl; + out << "// fennec, a free and open source game engine" << std::endl; + out << "// Copyright © 2025 Medusa Slockbower" << std::endl; + out << "//" << std::endl; + out << "// This program is free software: you can redistribute it and/or modify" << std::endl; + out << "// it under the terms of the GNU General Public License as published by" << std::endl; + out << "// the Free Software Foundation, either version 3 of the License, or" << std::endl; + out << "// (at your option) any later version." << std::endl; + out << "//" << std::endl; + out << "// This program is distributed in the hope that it will be useful," << std::endl; + out << "// but WITHOUT ANY WARRANTY; without even the implied warranty of" << std::endl; + out << "// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" << std::endl; + out << "// GNU General Public License for more details." << std::endl; + out << "//" << std::endl; + out << "// You should have received a copy of the GNU General Public License" << std::endl; + out << "// along with this program. If not, see ." << std::endl; + out << "// =====================================================================================================================" << std::endl; - flt << "" << std::endl; + out << "" << std::endl; - flt << "///" << std::endl; - flt << "/// \\file float.h" << std::endl; - flt << "/// \\brief metaprogramming floating point type info" << std::endl; - flt << "///" << std::endl; - flt << "///" << std::endl; - flt << "/// \\details this file is automatically generated for the current build environment" << std::endl; - flt << "///" << std::endl; - flt << "/// \\copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))" << std::endl; - flt << "///" << std::endl; - flt << "///" << std::endl; + out << "///" << std::endl; + out << "/// \\file float.h" << std::endl; + out << "/// \\brief metaprogramming floating point type info" << std::endl; + out << "///" << std::endl; + out << "///" << std::endl; + out << "/// \\details this file is automatically generated for the current build environment" << std::endl; + out << "///" << std::endl; + out << "/// \\copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))" << std::endl; + out << "///" << std::endl; + out << "///" << std::endl; - flt << "" << std::endl; + out << "" << std::endl; - flt << "#ifndef FENNEC_LANG_FLOAT_H" << std::endl; - flt << "#define FENNEC_LANG_FLOAT_H" << std::endl; + out << "#ifndef FENNEC_LANG_FLOAT_H" << std::endl; + out << "#define FENNEC_LANG_FLOAT_H" << std::endl; - flt << "" << std::endl; + out << "" << std::endl; - flt << "#include " << std::endl; + out << "#include " << std::endl; - flt << "" << std::endl; + out << "" << std::endl; // TODO: Fix this to generate info without using the c++stdlib for platforms without this available. - flt << "#define FLT_HAS_INFINITY " << std::dec << std::numeric_limits::has_infinity << std::endl; - flt << "#define FLT_HAS_QUIET_NAN " << std::dec << std::numeric_limits::has_quiet_NaN << std::endl; - flt << "#define FLT_HAS_SIGNALING_NAN " << std::dec << std::numeric_limits::has_signaling_NaN << std::endl; - flt << "#define FLT_HAS_DENORM " << std::dec << std::numeric_limits::has_denorm << std::endl; - flt << "#define FLT_HAS_DENORM_LOSS " << std::dec << std::numeric_limits::has_denorm_loss << std::endl; - flt << "#define FLT_ROUNDS " << std::dec << std::numeric_limits::round_style << std::endl; - flt << "#define FLT_IS_IEC559 " << std::dec << std::numeric_limits::is_iec559 << std::endl; - flt << "#define FLT_MANT_DIG " << std::dec << std::numeric_limits::digits << std::endl; - flt << "#define FLT_DIG " << std::dec << std::numeric_limits::digits10 << std::endl; - flt << "#define FLT_DECIMAL_DIG " << std::dec << std::numeric_limits::max_digits10 << std::endl; - flt << "#define FLT_RADIX " << std::dec << std::numeric_limits::radix << std::endl; - flt << "#define FLT_MIN_EXP " << std::dec << std::numeric_limits::min_exponent << std::endl; - flt << "#define FLT_MAX_EXP " << std::dec << std::numeric_limits::max_exponent << std::endl; - flt << "#define FLT_MIN_10_EXP " << std::dec << std::numeric_limits::min_exponent10 << std::endl; - flt << "#define FLT_MAX_10_EXP " << std::dec << std::numeric_limits::max_exponent10 << std::endl; - flt << "#define FLT_TRAPS " << std::dec << std::numeric_limits::traps << std::endl; - flt << "#define FLT_TINYNESS_BEFORE " << std::dec << std::numeric_limits::tinyness_before << std::endl; + out << "#define FLT_HAS_INFINITY " << std::dec << std::numeric_limits::has_infinity << std::endl; + out << "#define FLT_HAS_QUIET_NAN " << std::dec << std::numeric_limits::has_quiet_NaN << std::endl; + out << "#define FLT_HAS_SIGNALING_NAN " << std::dec << std::numeric_limits::has_signaling_NaN << std::endl; + out << "#define FLT_HAS_DENORM " << std::dec << std::numeric_limits::has_denorm << std::endl; + out << "#define FLT_HAS_DENORM_LOSS " << std::dec << std::numeric_limits::has_denorm_loss << std::endl; + out << "#define FLT_ROUNDS " << std::dec << std::numeric_limits::round_style << std::endl; + out << "#define FLT_IS_IEC559 " << std::dec << std::numeric_limits::is_iec559 << std::endl; + out << "#define FLT_MANT_DIG " << std::dec << std::numeric_limits::digits << std::endl; + out << "#define FLT_DIG " << std::dec << std::numeric_limits::digits10 << std::endl; + out << "#define FLT_DECIMAL_DIG " << std::dec << std::numeric_limits::max_digits10 << std::endl; + out << "#define FLT_RADIX " << std::dec << std::numeric_limits::radix << std::endl; + out << "#define FLT_MIN_EXP " << std::dec << std::numeric_limits::min_exponent << std::endl; + out << "#define FLT_MAX_EXP " << std::dec << std::numeric_limits::max_exponent << std::endl; + out << "#define FLT_MIN_10_EXP " << std::dec << std::numeric_limits::min_exponent10 << std::endl; + out << "#define FLT_MAX_10_EXP " << std::dec << std::numeric_limits::max_exponent10 << std::endl; + out << "#define FLT_TRAPS " << std::dec << std::numeric_limits::traps << std::endl; + out << "#define FLT_TINYNESS_BEFORE " << std::dec << std::numeric_limits::tinyness_before << std::endl; - flt << "#define FLT_MIN " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::min() ) << ")" << std::endl; - flt << "#define FLT_MAX " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::max() ) << ")" << std::endl; - flt << "#define FLT_EPSILON " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::epsilon() ) << ")" << std::endl; - flt << "#define FLT_INF " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::infinity() ) << ")" << std::endl; - flt << "#define FLT_QUIET_NAN " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::quiet_NaN() ) << ")" << std::endl; - flt << "#define FLT_SIGNALING_NAN " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::signaling_NaN()) << ")" << std::endl; - flt << "#define FLT_DENORM_MIN " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::denorm_min() ) << ")" << std::endl; - flt << "#define FLT_ROUND_ERR " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::round_error() ) << ")" << std::endl; + out << "#define FLT_MIN " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::min() ) << ")" << std::endl; + out << "#define FLT_MAX " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::max() ) << ")" << std::endl; + out << "#define FLT_EPSILON " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::epsilon() ) << ")" << std::endl; + out << "#define FLT_INF " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::infinity() ) << ")" << std::endl; + out << "#define FLT_QUIET_NAN " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::quiet_NaN() ) << ")" << std::endl; + out << "#define FLT_SIGNALING_NAN " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::signaling_NaN()) << ")" << std::endl; + out << "#define FLT_DENORM_MIN " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::denorm_min() ) << ")" << std::endl; + out << "#define FLT_ROUND_ERR " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::round_error() ) << ")" << std::endl; - flt << "" << std::endl; + out << "" << std::endl; - flt << "#define DBL_HAS_INFINITY " << std::dec << std::numeric_limits::has_infinity << std::endl; - flt << "#define DBL_HAS_QUIET_NAN " << std::dec << std::numeric_limits::has_quiet_NaN << std::endl; - flt << "#define DBL_HAS_SIGNALING_NAN " << std::dec << std::numeric_limits::has_signaling_NaN << std::endl; - flt << "#define DBL_HAS_DENORM " << std::dec << std::numeric_limits::has_denorm << std::endl; - flt << "#define DBL_HAS_DENORM_LOSS " << std::dec << std::numeric_limits::has_denorm_loss << std::endl; - flt << "#define DBL_ROUNDS " << std::dec << std::numeric_limits::round_style << std::endl; - flt << "#define DBL_IS_IEC559 " << std::dec << std::numeric_limits::is_iec559 << std::endl; - flt << "#define DBL_MANT_DIG " << std::dec << std::numeric_limits::digits << std::endl; - flt << "#define DBL_DIG " << std::dec << std::numeric_limits::digits10 << std::endl; - flt << "#define DBL_DECIMAL_DIG " << std::dec << std::numeric_limits::max_digits10 << std::endl; - flt << "#define DBL_RADIX " << std::dec << std::numeric_limits::radix << std::endl; - flt << "#define DBL_MIN_EXP " << std::dec << std::numeric_limits::min_exponent << std::endl; - flt << "#define DBL_MAX_EXP " << std::dec << std::numeric_limits::max_exponent << std::endl; - flt << "#define DBL_MIN_10_EXP " << std::dec << std::numeric_limits::min_exponent10 << std::endl; - flt << "#define DBL_MAX_10_EXP " << std::dec << std::numeric_limits::max_exponent10 << std::endl; - flt << "#define DBL_TRAPS " << std::dec << std::numeric_limits::traps << std::endl; - flt << "#define DBL_TINYNESS_BEFORE " << std::dec << std::numeric_limits::tinyness_before << std::endl; + out << "#define DBL_HAS_INFINITY " << std::dec << std::numeric_limits::has_infinity << std::endl; + out << "#define DBL_HAS_QUIET_NAN " << std::dec << std::numeric_limits::has_quiet_NaN << std::endl; + out << "#define DBL_HAS_SIGNALING_NAN " << std::dec << std::numeric_limits::has_signaling_NaN << std::endl; + out << "#define DBL_HAS_DENORM " << std::dec << std::numeric_limits::has_denorm << std::endl; + out << "#define DBL_HAS_DENORM_LOSS " << std::dec << std::numeric_limits::has_denorm_loss << std::endl; + out << "#define DBL_ROUNDS " << std::dec << std::numeric_limits::round_style << std::endl; + out << "#define DBL_IS_IEC559 " << std::dec << std::numeric_limits::is_iec559 << std::endl; + out << "#define DBL_MANT_DIG " << std::dec << std::numeric_limits::digits << std::endl; + out << "#define DBL_DIG " << std::dec << std::numeric_limits::digits10 << std::endl; + out << "#define DBL_DECIMAL_DIG " << std::dec << std::numeric_limits::max_digits10 << std::endl; + out << "#define DBL_RADIX " << std::dec << std::numeric_limits::radix << std::endl; + out << "#define DBL_MIN_EXP " << std::dec << std::numeric_limits::min_exponent << std::endl; + out << "#define DBL_MAX_EXP " << std::dec << std::numeric_limits::max_exponent << std::endl; + out << "#define DBL_MIN_10_EXP " << std::dec << std::numeric_limits::min_exponent10 << std::endl; + out << "#define DBL_MAX_10_EXP " << std::dec << std::numeric_limits::max_exponent10 << std::endl; + out << "#define DBL_TRAPS " << std::dec << std::numeric_limits::traps << std::endl; + out << "#define DBL_TINYNESS_BEFORE " << std::dec << std::numeric_limits::tinyness_before << std::endl; - flt << "#define DBL_MIN " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::min() ) << "l)" << std::endl; - flt << "#define DBL_MAX " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::max() ) << "l)" << std::endl; - flt << "#define DBL_EPSILON " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::epsilon() ) << "l)" << std::endl; - flt << "#define DBL_INF " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::infinity() ) << "l)" << std::endl; - flt << "#define DBL_QUIET_NAN " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::quiet_NaN() ) << "l)" << std::endl; - flt << "#define DBL_SIGNALING_NAN " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::signaling_NaN()) << "l)" << std::endl; - flt << "#define DBL_DENORM_MIN " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::denorm_min() ) << "l)" << std::endl; - flt << "#define DBL_ROUND_ERR " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::round_error() ) << "l)" << std::endl; + out << "#define DBL_MIN " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::min() ) << "l)" << std::endl; + out << "#define DBL_MAX " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::max() ) << "l)" << std::endl; + out << "#define DBL_EPSILON " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::epsilon() ) << "l)" << std::endl; + out << "#define DBL_INF " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::infinity() ) << "l)" << std::endl; + out << "#define DBL_QUIET_NAN " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::quiet_NaN() ) << "l)" << std::endl; + out << "#define DBL_SIGNALING_NAN " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::signaling_NaN()) << "l)" << std::endl; + out << "#define DBL_DENORM_MIN " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::denorm_min() ) << "l)" << std::endl; + out << "#define DBL_ROUND_ERR " << "fennec::bit_cast(0x" << std::hex << std::bit_cast(std::numeric_limits::round_error() ) << "l)" << std::endl; - flt << "" << std::endl; + out << "" << std::endl; - flt << "#endif // FENNEC_LANG_FLOAT_H" << std::endl; + out << "#endif // FENNEC_LANG_FLOAT_H" << std::endl; - flt.close(); + out.close(); - return 0; + return; } #endif //FLOAT_H diff --git a/metaprogramming/integer.h b/metaprogramming/integer.h new file mode 100644 index 0000000..af7307a --- /dev/null +++ b/metaprogramming/integer.h @@ -0,0 +1,253 @@ +// ===================================================================================================================== +// fennec, a free and open source game engine +// Copyright © 2025 Medusa Slockbower +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// ===================================================================================================================== + +#ifndef FENNEC_METAPROGRAMMING_INTEGER_H +#define FENNEC_METAPROGRAMMING_INTEGER_H + +#include + +inline void integer_h() +{ + + std::ofstream out("integer.h"); + + out << "// =====================================================================================================================" << std::endl; + out << "// fennec, a free and open source game engine" << std::endl; + out << "// Copyright © 2025 Medusa Slockbower" << std::endl; + out << "//" << std::endl; + out << "// This program is free software: you can redistribute it and/or modify" << std::endl; + out << "// it under the terms of the GNU General Public License as published by" << std::endl; + out << "// the Free Software Foundation, either version 3 of the License, or" << std::endl; + out << "// (at your option) any later version." << std::endl; + out << "//" << std::endl; + out << "// This program is distributed in the hope that it will be useful," << std::endl; + out << "// but WITHOUT ANY WARRANTY; without even the implied warranty of" << std::endl; + out << "// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" << std::endl; + out << "// GNU General Public License for more details." << std::endl; + out << "//" << std::endl; + out << "// You should have received a copy of the GNU General Public License" << std::endl; + out << "// along with this program. If not, see ." << std::endl; + out << "// =====================================================================================================================" << std::endl; + + out << "" << std::endl; + + out << "///" << std::endl; + out << "/// \\file integer.h" << std::endl; + out << "/// \\brief metaprogramming integer type info" << std::endl; + out << "///" << std::endl; + out << "///" << std::endl; + out << "/// \\details this file is automatically generated for the current build environment" << std::endl; + out << "///" << std::endl; + out << "/// \\copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))" << std::endl; + out << "///" << std::endl; + out << "///" << std::endl; + + out << "" << std::endl; + + out << "#ifndef FENNEC_LANG_INTEGER_H" << std::endl; + out << "#define FENNEC_LANG_INTEGER_H" << std::endl; + + out << "" << std::endl; + + out << "#undef WCHAR_MIN" << std::endl; + out << "#undef WCHAR_MAX" << std::endl; + + out << "" << std::endl; + + // TODO: Fix this to generate info without using the c++stdlib for platforms without this available. + + out << "#define CHAR_IS_SIGNED " << std::boolalpha << std::numeric_limits::is_signed << std::endl; + if(std::numeric_limits::is_signed) { + out << "#define CHAR_ROUNDS " << "0x" << std::hex << (int)std::numeric_limits::round_style << std::endl; + out << "#define CHAR_RADIX_DIG " << "0x" << std::hex << (int)std::numeric_limits::digits << std::endl; + out << "#define CHAR_DIG " << "0x" << std::hex << (int)std::numeric_limits::digits10 << std::endl; + out << "#define CHAR_DECIMAL_DIG " << "0x" << std::hex << (int)std::numeric_limits::max_digits10 << std::endl; + out << "#define CHAR_RADIX " << "0x" << std::hex << (int)std::numeric_limits::radix << std::endl; + out << "#define CHAR_TRAPS " << "0x" << std::boolalpha << std::numeric_limits::traps << std::endl; + + out << "#define CHAR_MIN " << "0x" << std::hex << (int)std::numeric_limits::min() << std::endl; + out << "#define CHAR_MAX " << "0x" << std::hex << (int)std::numeric_limits::max() << std::endl; + } + else { + out << "#define CHAR_ROUNDS " << "0x" << std::hex << (unsigned int)std::numeric_limits::round_style << std::endl; + out << "#define CHAR_RADIX_DIG " << "0x" << std::hex << (unsigned int)std::numeric_limits::digits << std::endl; + out << "#define CHAR_DIG " << "0x" << std::hex << (unsigned int)std::numeric_limits::digits10 << std::endl; + out << "#define CHAR_DECIMAL_DIG " << "0x" << std::hex << (unsigned int)std::numeric_limits::max_digits10 << std::endl; + out << "#define CHAR_RADIX " << "0x" << std::hex << (unsigned int)std::numeric_limits::radix << std::endl; + out << "#define CHAR_TRAPS " << "0x" << std::boolalpha << (unsigned int)std::numeric_limits::traps << std::endl; + + out << "#define CHAR_MIN " << "0x" << std::hex << (unsigned int)std::numeric_limits::min() << std::endl; + out << "#define CHAR_MAX " << "0x" << std::hex << (unsigned int)std::numeric_limits::max() << std::endl; + } + + out << "" << std::endl; + + out << "#define WCHAR_IS_SIGNED " << std::boolalpha << std::numeric_limits::is_signed << std::endl; + if(std::numeric_limits::is_signed) { + out << "#define WCHAR_ROUNDS " << "0x" << std::hex << (int)std::numeric_limits::round_style << std::endl; + out << "#define WCHAR_RADIX_DIG " << "0x" << std::hex << (int)std::numeric_limits::digits << std::endl; + out << "#define WCHAR_DIG " << "0x" << std::hex << (int)std::numeric_limits::digits10 << std::endl; + out << "#define WCHAR_DECIMAL_DIG " << "0x" << std::hex << (int)std::numeric_limits::max_digits10 << std::endl; + out << "#define WCHAR_RADIX " << "0x" << std::hex << (int)std::numeric_limits::radix << std::endl; + out << "#define WCHAR_TRAPS " << "0x" << std::boolalpha << std::numeric_limits::traps << std::endl; + + out << "#define WCHAR_MIN " << "0x" << std::hex << (int)std::numeric_limits::min() << std::endl; + out << "#define WCHAR_MAX " << "0x" << std::hex << (int)std::numeric_limits::max() << std::endl; + } + else { + out << "#define WCHAR_ROUNDS " << "0x" << std::hex << (unsigned int)std::numeric_limits::round_style << std::endl; + out << "#define WCHAR_RADIX_DIG " << "0x" << std::hex << (unsigned int)std::numeric_limits::digits << std::endl; + out << "#define WCHAR_DIG " << "0x" << std::hex << (unsigned int)std::numeric_limits::digits10 << std::endl; + out << "#define WCHAR_DECIMAL_DIG " << "0x" << std::hex << (unsigned int)std::numeric_limits::max_digits10 << std::endl; + out << "#define WCHAR_RADIX " << "0x" << std::hex << (unsigned int)std::numeric_limits::radix << std::endl; + out << "#define WCHAR_TRAPS " << "0x" << std::boolalpha << std::numeric_limits::traps << std::endl; + + out << "#define WCHAR_MIN " << "0x" << std::hex << (unsigned int)std::numeric_limits::min() << std::endl; + out << "#define WCHAR_MAX " << "0x" << std::hex << (unsigned int)std::numeric_limits::max() << std::endl; + } + + out << "" << std::endl; + + out << "#define SCHAR_ROUNDS " << "0x" << std::hex << (int)std::numeric_limits::round_style << std::endl; + out << "#define SCHAR_RADIX_DIG " << "0x" << std::hex << (int)std::numeric_limits::digits << std::endl; + out << "#define SCHAR_DIG " << "0x" << std::hex << (int)std::numeric_limits::digits10 << std::endl; + out << "#define SCHAR_DECIMAL_DIG " << "0x" << std::hex << (int)std::numeric_limits::max_digits10 << std::endl; + out << "#define SCHAR_RADIX " << "0x" << std::hex << (int)std::numeric_limits::radix << std::endl; + out << "#define SCHAR_TRAPS " << "0x" << std::boolalpha << std::numeric_limits::traps << std::endl; + + out << "#define SCHAR_MIN " << "0x" << std::hex << (int)std::numeric_limits::min() << std::endl; + out << "#define SCHAR_MAX " << "0x" << std::hex << (int)std::numeric_limits::max() << std::endl; + + out << "" << std::endl; + + out << "#define UCHAR_ROUNDS " << "0x" << std::hex << (unsigned int)std::numeric_limits::round_style << std::endl; + out << "#define UCHAR_RADIX_DIG " << "0x" << std::hex << (unsigned int)std::numeric_limits::digits << std::endl; + out << "#define UCHAR_DIG " << "0x" << std::hex << (unsigned int)std::numeric_limits::digits10 << std::endl; + out << "#define UCHAR_DECIMAL_DIG " << "0x" << std::hex << (unsigned int)std::numeric_limits::max_digits10 << std::endl; + out << "#define UCHAR_RADIX " << "0x" << std::hex << (unsigned int)std::numeric_limits::radix << std::endl; + out << "#define UCHAR_TRAPS " << "0x" << std::boolalpha << std::numeric_limits::traps << std::endl; + + out << "#define UCHAR_MIN " << "0x" << std::hex << (unsigned int)std::numeric_limits::min() << std::endl; + out << "#define UCHAR_MAX " << "0x" << std::hex << (unsigned int)std::numeric_limits::max() << std::endl; + + out << "" << std::endl; + + out << "#define SHORT_ROUNDS " << "0x" << std::hex << std::numeric_limits::round_style << std::endl; + out << "#define SHORT_RADIX_DIG " << "0x" << std::hex << std::numeric_limits::digits << std::endl; + out << "#define SHORT_DIG " << "0x" << std::hex << std::numeric_limits::digits10 << std::endl; + out << "#define SHORT_DECIMAL_DIG " << "0x" << std::hex << std::numeric_limits::max_digits10 << std::endl; + out << "#define SHORT_RADIX " << "0x" << std::hex << std::numeric_limits::radix << std::endl; + out << "#define SHORT_TRAPS " << "0x" << std::boolalpha << std::numeric_limits::traps << std::endl; + + out << "#define SHORT_MIN " << "0x" << std::hex << std::numeric_limits::min() << std::endl; + out << "#define SHORT_MAX " << "0x" << std::hex << std::numeric_limits::max() << std::endl; + + out << "" << std::endl; + + out << "#define USHORT_ROUNDS " << "0x" << std::hex << std::numeric_limits::round_style << std::endl; + out << "#define USHORT_RADIX_DIG " << "0x" << std::hex << std::numeric_limits::digits << std::endl; + out << "#define USHORT_DIG " << "0x" << std::hex << std::numeric_limits::digits10 << std::endl; + out << "#define USHORT_DECIMAL_DIG " << "0x" << std::hex << std::numeric_limits::max_digits10 << std::endl; + out << "#define USHORT_RADIX " << "0x" << std::hex << std::numeric_limits::radix << std::endl; + out << "#define USHORT_TRAPS " << "0x" << std::boolalpha << std::numeric_limits::traps << std::endl; + + out << "#define USHORT_MIN " << "0x" << std::hex << std::numeric_limits::min() << std::endl; + out << "#define USHORT_MAX " << "0x" << std::hex << std::numeric_limits::max() << std::endl; + + out << "" << std::endl; + + out << "#define INT_ROUNDS " << "0x" << std::hex << std::numeric_limits::round_style << std::endl; + out << "#define INT_RADIX_DIG " << "0x" << std::hex << std::numeric_limits::digits << std::endl; + out << "#define INT_DIG " << "0x" << std::hex << std::numeric_limits::digits10 << std::endl; + out << "#define INT_DECIMAL_DIG " << "0x" << std::hex << std::numeric_limits::max_digits10 << std::endl; + out << "#define INT_RADIX " << "0x" << std::hex << std::numeric_limits::radix << std::endl; + out << "#define INT_TRAPS " << "0x" << std::boolalpha << std::numeric_limits::traps << std::endl; + + out << "#define INT_MIN " << "0x" << std::hex << std::numeric_limits::min() << std::endl; + out << "#define INT_MAX " << "0x" << std::hex << std::numeric_limits::max() << std::endl; + + out << "" << std::endl; + + out << "#define UINT_ROUNDS " << "0x" << std::hex << std::numeric_limits::round_style << std::endl; + out << "#define UINT_RADIX_DIG " << "0x" << std::hex << std::numeric_limits::digits << std::endl; + out << "#define UINT_DIG " << "0x" << std::hex << std::numeric_limits::digits10 << std::endl; + out << "#define UINT_DECIMAL_DIG " << "0x" << std::hex << std::numeric_limits::max_digits10 << std::endl; + out << "#define UINT_RADIX " << "0x" << std::hex << std::numeric_limits::radix << std::endl; + out << "#define UINT_TRAPS " << "0x" << std::boolalpha << std::numeric_limits::traps << std::endl; + + out << "#define UINT_MIN " << "0x" << std::hex << std::numeric_limits::min() << std::endl; + out << "#define UINT_MAX " << "0x" << std::hex << std::numeric_limits::max() << std::endl; + + out << "" << std::endl; + + out << "#define LONG_ROUNDS " << "0x" << std::hex << std::numeric_limits::round_style << std::endl; + out << "#define LONG_RADIX_DIG " << "0x" << std::hex << std::numeric_limits::digits << std::endl; + out << "#define LONG_DIG " << "0x" << std::hex << std::numeric_limits::digits10 << std::endl; + out << "#define LONG_DECIMAL_DIG " << "0x" << std::hex << std::numeric_limits::max_digits10 << std::endl; + out << "#define LONG_RADIX " << "0x" << std::hex << std::numeric_limits::radix << std::endl; + out << "#define LONG_TRAPS " << "0x" << std::boolalpha << std::numeric_limits::traps << std::endl; + + out << "#define LONG_MIN " << "0x" << std::hex << std::numeric_limits::min() << std::endl; + out << "#define LONG_MAX " << "0x" << std::hex << std::numeric_limits::max() << std::endl; + + out << "" << std::endl; + + out << "#define ULONG_ROUNDS " << "0x" << std::hex << std::numeric_limits::round_style << std::endl; + out << "#define ULONG_RADIX_DIG " << "0x" << std::hex << std::numeric_limits::digits << std::endl; + out << "#define ULONG_DIG " << "0x" << std::hex << std::numeric_limits::digits10 << std::endl; + out << "#define ULONG_DECIMAL_DIG " << "0x" << std::hex << std::numeric_limits::max_digits10 << std::endl; + out << "#define ULONG_RADIX " << "0x" << std::hex << std::numeric_limits::radix << std::endl; + out << "#define ULONG_TRAPS " << "0x" << std::boolalpha << std::numeric_limits::traps << std::endl; + + out << "#define ULONG_MIN " << "0x" << std::hex << std::numeric_limits::min() << std::endl; + out << "#define ULONG_MAX " << "0x" << std::hex << std::numeric_limits::max() << std::endl; + + out << "" << std::endl; + + out << "#define LLONG_ROUNDS " << "0x" << std::hex << std::numeric_limits::round_style << std::endl; + out << "#define LLONG_RADIX_DIG " << "0x" << std::hex << std::numeric_limits::digits << std::endl; + out << "#define LLONG_DIG " << "0x" << std::hex << std::numeric_limits::digits10 << std::endl; + out << "#define LLONG_DECIMAL_DIG " << "0x" << std::hex << std::numeric_limits::max_digits10 << std::endl; + out << "#define LLONG_RADIX " << "0x" << std::hex << std::numeric_limits::radix << std::endl; + out << "#define LLONG_TRAPS " << "0x" << std::boolalpha << std::numeric_limits::traps << std::endl; + + out << "#define LLONG_MIN " << "0x" << std::hex << std::numeric_limits::min() << std::endl; + out << "#define LLONG_MAX " << "0x" << std::hex << std::numeric_limits::max() << std::endl; + + out << "" << std::endl; + + out << "#define ULLONG_ROUNDS " << "0x" << std::hex << std::numeric_limits::round_style << std::endl; + out << "#define ULLONG_RADIX_DIG " << "0x" << std::hex << std::numeric_limits::digits << std::endl; + out << "#define ULLONG_DIG " << "0x" << std::hex << std::numeric_limits::digits10 << std::endl; + out << "#define ULLONG_DECIMAL_DIG " << "0x" << std::hex << std::numeric_limits::max_digits10 << std::endl; + out << "#define ULLONG_RADIX " << "0x" << std::hex << std::numeric_limits::radix << std::endl; + out << "#define ULLONG_TRAPS " << "0x" << std::boolalpha << std::numeric_limits::traps << std::endl; + + out << "#define ULLONG_MIN " << "0x" << std::hex << std::numeric_limits::min() << std::endl; + out << "#define ULLONG_MAX " << "0x" << std::hex << std::numeric_limits::max() << std::endl; + + out << "" << std::endl; + + out << "#endif // FENNEC_LANG_INTEGER_H" << std::endl; + + out.close(); + + return; +} + +#endif // FENNEC_METAPROGRAMMING_INTEGER_H diff --git a/metaprogramming/main.cpp b/metaprogramming/main.cpp index 2ed40a3..09c88a8 100644 --- a/metaprogramming/main.cpp +++ b/metaprogramming/main.cpp @@ -19,6 +19,11 @@ #include #include +#include "float.h" +#include "integer.h" + int main(int, const char**) { + float_h(); + integer_h(); }