Initial Commit

This commit is contained in:
2025-05-25 22:36:59 -04:00
commit a6442e1945
64 changed files with 20486 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
// =====================================================================================================================
// 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 <https://www.gnu.org/licenses/>.
// =====================================================================================================================
///
/// \file conditional_types.h
/// \brief metaprogramming to conditionally set a type
///
///
/// \details
/// \author Medusa Slockbower
///
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
///
///
#ifndef CONDITIONAL_TYPES_H
#define CONDITIONAL_TYPES_H
#include <fennec/lang/type_transforms.h>
#include <fennec/lang/types.h>
namespace fennec
{
// fennec::conditional =================================================================================================
///
///
/// \brief select between two types based on a condition
///
/// \details
/// \tparam B the value of the condition
/// \tparam T type to use when \f$B == true\f$
/// \tparam F type to use when \f$B == false\f$
template<bool_t B, typename T, typename F> struct conditional;
/// \brief Shorthand for ```typename conditional<ConditionV, TrueT, FalseT>::type```
template<bool_t B, typename T, typename F> using conditional_t = typename conditional<B, T, F>::type;
/// \internal specialization of fennec::conditional for \c true case
template<typename T, typename F> struct conditional<true, T, F> : type_transform<T>{};
/// \internal specialization of fennec::conditional for \c false case
template<typename T, typename F> struct conditional<false, T, F> : type_transform<F>{};
}
#endif //CONDITIONAL_TYPES_H

View File

@@ -0,0 +1,78 @@
// =====================================================================================================================
// 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 <https://www.gnu.org/licenses/>.
// =====================================================================================================================
///
/// \file constants.h
/// \brief metaprogramming constants
///
///
/// \details
/// \author Medusa Slockbower
///
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
///
///
#ifndef FENNEC_LANG_CONSTANTS_H
#define FENNEC_LANG_CONSTANTS_H
#include <fennec/lang/types.h>
namespace fennec
{
///
/// \brief metaprogramming integral constant
///
/// \details
/// \tparam T type of the constant
/// \tparam V value of the constant
template<typename T, T V> struct integral_constant
{
///
/// \brief value of the constant
inline static constexpr T value = V;
///
///
/// \brief cast operator to allow for braced initialization
/// \returns the value of the constant
constexpr operator T() const noexcept { return V; }
};
///
///
/// \brief metaprogramming boolean constant
///
/// \details
/// \tparam V value of the constant
template<bool_t V> struct bool_constant : integral_constant<bool_t, V> {};
///
///
/// \brief metaprogramming true constant
struct true_type : bool_constant<true> {};
///
///
/// \brief metaprogramming false constant
struct false_type : bool_constant<false> {};
}
#endif // FENNEC_LANG_CONSTANTS_H

View File

@@ -0,0 +1,70 @@
// =====================================================================================================================
// 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 <https://www.gnu.org/licenses/>.
// =====================================================================================================================
/// \file __type_traits.h
/// \internal
#ifndef FENNEC_LANG_DETAIL_TYPE_TRAITS_H
#define FENNEC_LANG_DETAIL_TYPE_TRAITS_H
#include <fennec/lang/constants.h>
#include <fennec/lang/type_traits.h>
#include <fennec/lang/float.h>
namespace fennec
{
namespace detail
{
template<typename> struct __is_void_helper : false_type {};
template<> struct __is_void_helper<void> : true_type {};
template<typename> struct __is_bool_helper : false_type {};
template<> struct __is_bool_helper<bool_t> : true_type {};
template<typename> struct __is_integral_helper : false_type {};
template<> struct __is_integral_helper<bool_t> : true_type {};
template<> struct __is_integral_helper<char_t> : true_type {};
template<> struct __is_integral_helper<char8_t> : true_type {};
template<> struct __is_integral_helper<char16_t> : true_type {};
template<> struct __is_integral_helper<char32_t> : true_type {};
template<> struct __is_integral_helper<schar_t> : true_type {};
template<> struct __is_integral_helper<uchar_t> : true_type {};
template<> struct __is_integral_helper<wchar_t> : true_type {};
template<> struct __is_integral_helper<short_t> : true_type {};
template<> struct __is_integral_helper<ushort_t> : true_type {};
template<> struct __is_integral_helper<int_t> : true_type {};
template<> struct __is_integral_helper<uint_t> : true_type {};
template<> struct __is_integral_helper<long_t> : true_type {};
template<> struct __is_integral_helper<ulong_t> : true_type {};
template<> struct __is_integral_helper<llong_t> : true_type {};
template<> struct __is_integral_helper<ullong_t> : true_type {};
template<typename TypeT> struct __is_signed_helper : bool_constant<TypeT(-1) < TypeT(0)> {};
template<typename TypeT> struct __is_unsigned_helper : bool_constant<TypeT(-1) >= TypeT(0)> {};
template<typename> struct __is_floating_point_helper : false_type {};
template<> struct __is_floating_point_helper<float_t> : true_type {};
template<> struct __is_floating_point_helper<double_t> : true_type {};
}
}
#endif // FENNEC_LANG_DETAIL_TYPE_TRAITS_H

View File

@@ -0,0 +1,82 @@
// =====================================================================================================================
// 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 <https://www.gnu.org/licenses/>.
// =====================================================================================================================
///
/// \file float.h
/// \brief metaprogramming floating point 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))
///
///
#include <fennec/memory/bits.h>
#define FLT_HAS_INFINITY 1
#define FLT_HAS_QUIET_NAN 1
#define FLT_HAS_SIGNALING_NAN 1
#define FLT_HAS_DENORM 1
#define FLT_HAS_DENORM_LOSS 0
#define FLT_ROUNDS 1
#define FLT_IS_IEC559 1
#define FLT_MANT_DIG 24
#define FLT_DIG 6
#define FLT_DECIMAL_DIG 9
#define FLT_RADIX 2
#define FLT_MIN_EXP -125
#define FLT_MAX_EXP 128
#define FLT_MIN_10_EXP -37
#define FLT_MAX_10_EXP 38
#define FLT_TRAPS 0
#define FLT_TINYNESS_BEFORE 0
#define FLT_MIN fennec::bit_cast<float>(0x800000)
#define FLT_MAX fennec::bit_cast<float>(0x7f7fffff)
#define FLT_EPSILON fennec::bit_cast<float>(0x34000000)
#define FLT_INF fennec::bit_cast<float>(0x7f800000)
#define FLT_QUIET_NAN fennec::bit_cast<float>(0x7fc00000)
#define FLT_SIGNALING_NAN fennec::bit_cast<float>(0x7fa00000)
#define FLT_DENORM_MIN fennec::bit_cast<float>(0x1)
#define FLT_ROUND_ERR fennec::bit_cast<float>(0x3f000000)
#define DBL_HAS_INFINITY 1
#define DBL_HAS_QUIET_NAN 1
#define DBL_HAS_SIGNALING_NAN 1
#define DBL_HAS_DENORM 1
#define DBL_HAS_DENORM_LOSS 0
#define DBL_ROUNDS 1
#define DBL_IS_IEC559 1
#define DBL_MANT_DIG 53
#define DBL_DIG 15
#define DBL_DECIMAL_DIG 17
#define DBL_RADIX 2
#define DBL_MIN_EXP -1021
#define DBL_MAX_EXP 1024
#define DBL_MIN_10_EXP -307
#define DBL_MAX_10_EXP 308
#define DBL_TRAPS 0
#define DBL_TINYNESS_BEFORE 0
#define DBL_MIN fennec::bit_cast<double>(0x10000000000000l)
#define DBL_MAX fennec::bit_cast<double>(0x7fefffffffffffffl)
#define DBL_EPSILON fennec::bit_cast<double>(0x3cb0000000000000l)
#define DBL_INF fennec::bit_cast<double>(0x7ff0000000000000l)
#define DBL_QUIET_NAN fennec::bit_cast<double>(0x7ff8000000000000l)
#define DBL_SIGNALING_NAN fennec::bit_cast<double>(0x7ff4000000000000l)
#define DBL_DENORM_MIN fennec::bit_cast<double>(0x1l)
#define DBL_ROUND_ERR fennec::bit_cast<double>(0x3fe0000000000000l)

View File

@@ -0,0 +1,27 @@
// =====================================================================================================================
// fennec, a free and open source game engine
// Copyright (C) 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 <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#ifndef FENNEC_LANG_INTRINSICS_H
#define FENNEC_LANG_INTRINSICS_H
# if defined(__has_builtin)
# define FENNEC_HAS_BUILTIN_BITCAST __has_builtin(__builtin_bit_cast)
# endif
#endif // FENNEC_LANG_INTRINSICS_H

View File

@@ -0,0 +1,154 @@
// =====================================================================================================================
// fennec, a free and open source game engine
// Copyright (C) 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 <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#ifndef FENNEC_LANG_LIMITS_H
#define FENNEC_LANG_LIMITS_H
#include <cmath>
#include <fennec/lang/types.h>
#include <fennec/lang/type_traits.h>
namespace fennec
{
enum float_round_style
{
round_indeterminate = -1
, round_toward_zero = 0
, round_to_nearest = 1
, round_toward_infinity = 2
, round_toward_neg_infinity = 3
};
template<typename TypeT> struct numeric_limits
{
static constexpr bool is_specialized = false;
static constexpr bool is_signed = false;
static constexpr bool is_integer = false;
static constexpr bool is_exact = false;
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 = false;
static constexpr bool is_modulo = false;
static constexpr bool tinyness_before = false;
static constexpr bool traps = false;
static constexpr int digits = 0;
static constexpr int digits10 = 0;
static constexpr int max_digits10 = 0;
static constexpr int radix = 0;
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 float_round_style rounding_style = round_indeterminate;
static constexpr TypeT min() { return TypeT(); }
static constexpr TypeT max() { return TypeT(); }
static constexpr TypeT lowest() { return TypeT(); }
static constexpr TypeT epsilon() { return TypeT(); }
static constexpr TypeT round_error() { return TypeT(); }
static constexpr TypeT infinity() { return TypeT(); }
static constexpr TypeT quiet_NaN() { return TypeT(); }
static constexpr TypeT signaling_NaN() { return TypeT(); }
static constexpr TypeT denorm_min() { return TypeT(); }
};
template<> struct numeric_limits<float>
{
static constexpr bool is_specialized = true;
static constexpr bool is_signed = true;
static constexpr bool is_integer = false;
static constexpr bool is_exact = false;
static constexpr bool has_infinity = FLT_HAS_INFINITY;
static constexpr bool has_quiet_nan = FLT_HAS_QUIET_NAN;
static constexpr bool has_signaling_nan = FLT_HAS_SIGNALING_NAN;
static constexpr bool has_denorm = FLT_HAS_DENORM;
static constexpr bool has_denorm_loss = FLT_HAS_DENORM_LOSS;
static constexpr bool is_iec559 = FLT_IS_IEC559;
static constexpr bool is_bounded = true;
static constexpr bool is_modulo = false;
static constexpr bool tinyness_before = FLT_TINYNESS_BEFORE;
static constexpr bool traps = FLT_TRAPS;
static constexpr int digits = FLT_MANT_DIG;
static constexpr int digits10 = FLT_DIG;
static constexpr int max_digits10 = FLT_DECIMAL_DIG;
static constexpr int radix = FLT_RADIX;
static constexpr int min_exponent = FLT_MIN_EXP;
static constexpr int min_exponent10 = FLT_MIN_10_EXP;
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 max() { return FLT_MAX; }
static constexpr double lowest() { return -FLT_MAX; }
static constexpr double epsilon() { return FLT_EPSILON; }
static constexpr double round_error() { return FLT_ROUND_ERR; }
static constexpr double infinity() { return FLT_INF; }
static constexpr double quiet_NaN() { return FLT_QUIET_NAN; }
static constexpr double signaling_NaN() { return FLT_SIGNALING_NAN; }
static constexpr double denorm_min() { return FLT_DENORM_MIN; }
};
template<> struct numeric_limits<double>
{
static constexpr bool is_specialized = true;
static constexpr bool is_signed = true;
static constexpr bool is_integer = false;
static constexpr bool is_exact = false;
static constexpr bool has_infinity = DBL_HAS_INFINITY;
static constexpr bool has_quiet_nan = DBL_HAS_QUIET_NAN;
static constexpr bool has_signaling_nan = DBL_HAS_SIGNALING_NAN;
static constexpr bool has_denorm = DBL_HAS_DENORM;
static constexpr bool has_denorm_loss = DBL_HAS_DENORM_LOSS;
static constexpr bool is_iec559 = DBL_IS_IEC559;
static constexpr bool is_bounded = true;
static constexpr bool is_modulo = false;
static constexpr bool tinyness_before = DBL_TINYNESS_BEFORE;
static constexpr bool traps = DBL_TRAPS;
static constexpr int digits = DBL_MANT_DIG;
static constexpr int digits10 = DBL_DIG;
static constexpr int max_digits10 = DBL_DECIMAL_DIG;
static constexpr int radix = DBL_RADIX;
static constexpr int min_exponent = DBL_MIN_EXP;
static constexpr int min_exponent10 = DBL_MIN_10_EXP;
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 max() { return DBL_MAX; }
static constexpr double lowest() { return -DBL_MAX; }
static constexpr double epsilon() { return DBL_EPSILON; }
static constexpr double round_error() { return DBL_ROUND_ERR; }
static constexpr double infinity() { return DBL_INF; }
static constexpr double quiet_NaN() { return DBL_QUIET_NAN; }
static constexpr double signaling_NaN() { return DBL_SIGNALING_NAN; }
static constexpr double denorm_min() { return DBL_DENORM_MIN; }
};
}
#endif // FENNEC_LANG_LIMITS_H

View File

@@ -0,0 +1,225 @@
// =====================================================================================================================
// 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 <https://www.gnu.org/licenses/>.
// =====================================================================================================================
///
/// \file sequences.h
/// \brief metaprogramming sequences
///
///
/// \details
/// \author Medusa Slockbower
///
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
///
///
#ifndef FENNEC_LANG_SEQUENCES_H
#define FENNEC_LANG_SEQUENCES_H
#include <fennec/lang/type_traits.h>
namespace fennec
{
// fennec::sequence ====================================================================================================
///
///
/// \brief metaprogramming sequence
///
/// \details
/// \tparam ValueT type of the values
/// \tparam ValuesV sequence values
///
template<typename ValueT, ValueT...ValuesV> struct sequence
{
///
/// \brief type of the sequence
using value_type = ValueT;
///
/// \brief self-referential type
using type = sequence;
///
///
/// \brief returns the number of elements
///
/// \return number of elements in the array
inline static constexpr size_t size() noexcept { return sizeof...(ValuesV); }
};
// fennec::integer_sequence ============================================================================================
///
///
/// \brief metaprogramming integral sequence
///
/// \details
/// \tparam T type of the values, must satisfy ```fennec::is_integral<T>```
/// \tparam Values sequence values
///
template<typename T, T...Values> requires(is_integral_v<T>)
struct integer_sequence : sequence<T, Values...>
{
///
/// \brief type of the sequence
using value_type = T;
///
/// \brief self-referential type
using type = integer_sequence;
///
///
/// \brief returns the number of elements
///
/// \return number of elements in the array
inline static constexpr size_t size() noexcept { return sizeof...(Values); }
};
///
///
/// \brief generate a fennec::integer_sequence \f$\left[\,0\,\ldots\,N\,\right)\f$
///
/// \details
/// \tparam T type of the values, must satisfy ```fennec::is_integral<T>```
/// \tparam N size of the sequence to generate
///
template<typename T, size_t N> struct make_integer_sequence;
///
/// \brief shorthand for ```typename make_integer_sequence<T, N>::type```
template<typename T, size_t N> using make_integer_sequence_t = typename make_integer_sequence<T, N>::type;
// fennec::index_sequence ==============================================================================================
///
///
/// \brief metaprogramming integral sequence
///
/// \details
/// \tparam Indices sequence values
///
template<size_t...Indices> struct index_sequence : integer_sequence<size_t, Indices...>
{
///
/// \brief type of the sequence
using value_type = size_t;
///
/// \brief self-referential type
using type = index_sequence;
///
///
/// \brief returns the number of elements
///
/// \return number of elements in the array
inline static constexpr size_t size() noexcept { return sizeof...(Indices); }
};
///
///
/// \brief generate a fennec::index_sequence \f$\left[\,0\,\ldots\,N\,\right)\f$
///
/// \details
/// \tparam T type of the values, must satisfy ```fennec::is_integral<T>```
/// \tparam N size of the sequence to generate
///
template<size_t N> struct make_index_sequence;
///
/// \brief shorthand for ```typename make_index_sequence<N>::type```
template<size_t N> using make_index_sequence_t = typename make_index_sequence<N>::type;
// fennec::concat_sequence =============================================================================================
///
///
/// \brief concatenate two sequences
///
/// \details
/// \tparam SequenceT0 lhs
/// \tparam SequenceT1 rhs
template<typename SequenceT0, typename SequenceT1> struct concat_sequence;
///
/// \brief shorthand for ```typename concat_sequence<SequenceT0, SequenceT1>::type```
template<typename SequenceT0, typename SequenceT1> using concat_sequence_t
= typename concat_sequence<SequenceT0, SequenceT1>::type;
///
///
/// \brief specialization to concatenate two integer sequences
///
/// \details
/// \tparam T integral type
/// \tparam SequenceT0 lhs
/// \tparam SequenceT1 rhs
template<typename T, T...SequenceV0, T...SequenceV1>
struct concat_sequence<integer_sequence<T, SequenceV0...>, integer_sequence<T, SequenceV1...>>
: integer_sequence<T, SequenceV0..., (sizeof...(SequenceV0) + SequenceV1)...>{};
///
///
/// \brief specialization to concatenate two index sequences
///
/// \details
/// \tparam SequenceT0 lhs
/// \tparam SequenceT1 rhs
template<size_t...SequenceV0, size_t...SequenceV1>
struct concat_sequence<index_sequence<SequenceV0...>, index_sequence<SequenceV1...>>
: index_sequence<SequenceV0..., (sizeof...(SequenceV0) + SequenceV1)...>{};
// Internal ============================================================================================================
/// \internal Implementation for Generating an \ref integer_sequence
template<typename T, size_t N> struct make_integer_sequence : concat_sequence_t<make_integer_sequence_t<T, N / 2>, make_integer_sequence_t<T, N - N / 2>>{};
/// \internal Base Case of \f$N=0\f$
template<typename T> struct make_integer_sequence<T, 0> : integer_sequence<T> {};
/// \internal Base Case of \f$N=1\f$
template<typename T> struct make_integer_sequence<T, 1> : integer_sequence<T, 0>{};
/// \internal Implementation for Generating an \ref integer_sequence
template<size_t N> struct make_index_sequence : concat_sequence_t<make_index_sequence_t<N / 2>, make_index_sequence_t<N - N / 2>>{};
/// \internal Base Case of \f$N=0\f$
template<> struct make_index_sequence<0> : index_sequence<> {};
/// \internal Base Case of \f$N=1\f$
template<> struct make_index_sequence<1> : index_sequence<0>{};
}
#endif // FENNEC_LANG_SEQUENCES_H

View File

@@ -0,0 +1,195 @@
// =====================================================================================================================
// 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 <https://www.gnu.org/licenses/>.
// =====================================================================================================================
///
/// \file type_traits.h
/// \brief get info about types at compile-time
///
///
/// \details
/// \author Medusa Slockbower
///
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
///
///
#ifndef FENNEC_LANG_TYPE_TRAITS_H
#define FENNEC_LANG_TYPE_TRAITS_H
#include <fennec/lang/type_transforms.h>
#include <fennec/lang/detail/__type_traits.h>
namespace fennec
{
// fennec::is_void =====================================================================================================
///
///
/// \brief check if \p T is of type void
///
/// \details
/// \tparam T type to check
template<typename T> struct is_void
: detail::__is_void_helper<remove_cvr_t<T>>{};
///
///
/// \brief shorthand for ```is_void<T>::value```
/// \tparam T type to check
template<typename T> constexpr bool_t is_void_v
= is_void<T>::value;
// fennec::is_bool =====================================================================================================
///
///
/// \brief check if \p T is of type bool
///
/// \details
/// \tparam T type to check
template<typename T> struct is_bool
: detail::__is_bool_helper<remove_cvr_t<T>>{};
///
///
/// \brief shorthand for ```is_bool<T>::value```
/// \tparam T type to check
template<typename T> constexpr bool_t is_bool_v
= is_bool<T>::value;
// Integral Types ======================================================================================================
///
///
/// \brief check if \p T is of an integral
///
/// \details
/// \tparam T type to check
template<typename T> struct is_integral
: detail::__is_integral_helper<remove_cvr_t<T>> {};
///
///
/// \brief shorthand for ```is_integral<T>::value```
/// \tparam T type to check
template<typename T> constexpr bool_t is_integral_v
= is_integral<T>::value;
///
///
/// \brief check if \p T is of a signed integral
///
/// \details
/// \tparam T type to check
template<typename T> struct is_signed
: detail::__is_signed_helper<remove_cvr_t<T>> {};
///
///
/// \brief shorthand for ```is_signed<T>::value```
/// \tparam T type to check
template<typename T> constexpr bool_t is_signed_v
= is_signed<T>::value;
///
///
/// \brief check if \p T is of an unsigned integral
///
/// \details
/// \tparam T type to check
template<typename T> struct is_unsigned
: detail::__is_unsigned_helper<remove_cvr_t<T>> {};
///
///
/// \brief shorthand for ```is_unsigned<T>::value```
/// \tparam T type to check
template<typename T> constexpr bool_t is_unsigned_v
= is_unsigned<T>::value;
// Floating Point Types ================================================================================================
///
///
/// \brief check if \p T is of a floating point type
///
/// \details
/// \tparam T type to check
template<typename T> struct is_floating_point
: detail::__is_floating_point_helper<remove_cvr_t<T>>{};
///
///
/// \brief shorthand for ```is_floating_point<T>::value```
/// \tparam T type to check
template<typename T> constexpr bool_t is_floating_point_v
= is_floating_point<T> {};
// Arithmetic Types ====================================================================================================
///
///
/// \brief check if \p T is an arithmetic type
///
/// \details
/// \tparam T type to check
template<typename T> struct is_arithmetic
: bool_constant<is_integral_v<T> or is_floating_point_v<T>>{};
///
///
/// \brief shorthand for ```is_arithmetic<T>::value```
/// \tparam T type to check
template<typename T> constexpr bool_t is_arithmetic_v
= is_arithmetic<T>::value;
// fennec::is_same =====================================================================================================
///
///
/// \brief check if
///
/// \details
/// \tparam T type to check
template<typename T0, typename T1> struct is_same
: false_type {};
template<typename T> struct is_same<T, T>
: true_type {};
///
///
/// \brief shorthand for ```is_same<T0, T1>::value```
/// \tparam T type to check
template<typename T0, typename T1> constexpr bool_t is_same_v
= is_same<T0, T1> {};
}
#endif // FENNEC_LANG_TYPE_TRAITS_H

View File

@@ -0,0 +1,276 @@
// =====================================================================================================================
// 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 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 License for more details.
//
// You should have received a copy of the GNU General License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================
///
/// \file type_transforms.h
/// \brief modify types at compile time
///
///
/// \details
/// \author Medusa Slockbower
///
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
///
///
#ifndef FENNEC_LANG_TYPE_TRANSFORMS_H
#define FENNEC_LANG_TYPE_TRANSFORMS_H
namespace fennec
{
// fennec::type_transform ==============================================================================================
///
/// \struct fennec::type_transform
/// \brief Base Class for Type Transformations
///
/// \details resembles a transformation from one type to T, the result is stored in the typedef type_transform::type
/// \tparam T Resultant Type
template<typename T> struct type_transform {
///
/// \typedef type_transform::type
/// \brief the type to transform into
using type = T;
};
// 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*```
/// \tparam T Resultant Type
template<typename T> struct add_pointer : type_transform<T*>{};
///
/// \typedef fennec::add_pointer_t
/// \brief shorthand for ```typename add_pointer<T>::type```
template<typename T> using add_pointer_t = typename add_pointer<T>::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```
/// \tparam T Resultant Type
template<typename T> struct remove_pointer : type_transform<T> {};
/// \internal specialization for T*
template<typename T> struct remove_pointer<T*> : type_transform<T> {};
///
/// \typedef fennec::remove_pointer_t
/// \brief shorthand for ```typename remove_pointer<T>::type```
template<typename T> using remove_pointer_t = typename remove_pointer<T>::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&```
/// \tparam T Resultant Type
template<typename T> struct add_reference : type_transform<T&> {};
///
/// \typedef fennec::add_reference_t
/// \brief shorthand for ```typename add_reference<T>::type```
template<typename T> using add_reference_t = typename add_reference<T>::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```
/// \tparam T Reference Type
template<typename T> struct remove_reference : type_transform<T> {};
/// \internal specialization for ```T&```
template<typename T> struct remove_reference<T&> : type_transform<T> {};
/// \internal specialization for ```T&&```
template<typename T> struct remove_reference<T&&> : type_transform<T> {};
///
/// \typedef fennec::remove_reference_t
/// \brief shorthand for ```typename remove_reference<T>::type```
template<typename T> using remove_reference_t = typename remove_reference<T>::type;
// 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```
/// \tparam T Reference Type
template<typename T> struct add_const : type_transform<const T> {};
///
/// \typedef fennec::add_const_t
/// \brief shorthand for ```typename add_const<T>::type```
template<typename T> using add_const_t = typename add_const<T>::type;
/// \internal specialization for const types
template<typename T> struct add_const<const T> : type_transform<const T> {};
///
/// \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```
/// \tparam T Reference Type
template<typename T> struct remove_const : type_transform<T> {};
///
/// \typedef fennec::remove_const_t
/// \brief shorthand for ```typename remove_const<T>::type```
template<typename T> using remove_const_t = typename remove_const<T>::type;
/// \internal specialization for const types
template<typename T> struct remove_const<const T> : type_transform<T> {};
///
/// \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```
/// \tparam T Reference Type
template<typename T> struct add_volatile : type_transform<volatile T> {};
///
/// \typedef fennec::add_volatile_t
/// \brief shorthand for ```typename add_volatile<T>::type```
template<typename T> using add_volatile_t = typename add_volatile<T>::type;
/// \internal specialization for volatile types
template<typename T> struct add_volatile<volatile T> : type_transform<volatile T> {};
///
/// \struct fennec::remove_volatile
/// \brief remove the volatile qualifier from the provided type \p T
///
/// \details removes references from the provided type such that ```volatile T``` becomes ```T```
/// \tparam T Reference Type
template<typename T> struct remove_volatile : type_transform<T> {};
///
/// \typedef fennec::remove_volatile_t
/// \brief shorthand for ```typename remove_volatile<T>::type```
template<typename T> using remove_volatile_t = typename remove_volatile<T>::type;
/// \internal specialization for volatile types
template<typename T> struct remove_volatile<volatile T> : type_transform<T> {};
///
/// \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```
/// \tparam T Reference Type
template<typename T> struct add_cv : type_transform<const volatile T> {};
///
/// \typedef fennec::add_cv_t
/// \brief shorthand for ```typename add_cv<T>::type```
template<typename T> using add_cv_t = typename add_cv<T>::type;
/// \internal specialization for const types
template<typename T> struct add_cv<const T> : type_transform<const volatile T> {};
/// \internal specialization for volatile types
template<typename T> struct add_cv<volatile T> : type_transform<const volatile T> {};
/// \internal specialization for const volatile types
template<typename T> struct add_cv<const volatile T> : type_transform<const volatile T> {};
///
///
/// \brief remove the const and volatile qualifiers from the provided type \p T
///
/// \details removes const and volatile from the provided type such that ```const T```, ```volatile T```, and
/// ```const volatile T``` become ```T```
/// \tparam T Reference Type
template<typename T> struct remove_cv : type_transform<T> {};
/// \internal specialization for const types
template<typename T> struct remove_cv<const T> : type_transform<T> {};
/// \internal specialization for volatile types
template<typename T> struct remove_cv<volatile T> : type_transform<T> {};
/// \internal specialization for const volatile types
template<typename T> struct remove_cv<const volatile T> : type_transform<T> {};
///
/// \brief shorthand for ```typename remove_cv<T>::type```
template<typename T> using remove_cv_t = typename remove_cv<T>::type;
///
///
/// \brief add a reference and the const volatile qualifiers from the provided type \p T
///
/// \details adds references and const volatile qualifiers to the provided type.
/// \tparam T Reference Type
template<typename T> struct add_cvr : type_transform<add_reference_t<add_cv_t<T>>> {};
///
/// \brief shorthand for ```typename add_cvr<T>::type```
template<typename T> using add_cvr_t = typename add_cvr<T>::type;
///
///
/// \brief removes references as well as the const and volatile qualifiers from the provided type \p T
///
/// \details removes const and volatile from the provided type such that
/// \tparam T Reference Type
template<typename T> struct remove_cvr : type_transform<remove_cv_t<remove_reference_t<T>>> {};
///
/// \brief shorthand for ```typename remove_cvr<T>::type```
template<typename T> using remove_cvr_t = typename remove_cvr<T>::type;
}
#endif // FENNEC_LANG_TYPE_TRANSFORMS_H

204
include/fennec/lang/types.h Normal file
View File

@@ -0,0 +1,204 @@
// =====================================================================================================================
// 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 <https://www.gnu.org/licenses/>.
// =====================================================================================================================
///
/// \file types.h
/// \brief basic types of the c++ language
///
///
/// \details
/// \author Medusa Slockbower
///
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
///
///
#ifndef FENNEC_LANG_TYPES_H
#define FENNEC_LANG_TYPES_H
#include <cstdint>
namespace fennec
{
// Basic Types =========================================================================================================
///
/// \name Basic Types
/// @{
///
/// \brief A conditional type
using bool_t = bool;
///
/// \brief A type capable of holding an ascii value
using char_t = char;
///
/// \brief A type with the size of a char, capable of holding a signed 8-bit integer
using schar_t = signed char;
///
/// \brief A type with the size of a char, capable of holding an unsigned 8-bit integer
using uchar_t = unsigned char;
///
/// \brief A short type, capable of holding signed 16-bit integer
using short_t = signed short;
///
/// \brief A short type, capable of holding an unsigned signed 16-bit integer
using ushort_t = unsigned short;
///
/// \brief A signed integer type, size varies by implementation, but typically 32-bit
using int_t = signed int;
///
/// \brief An unsigned integer type, size varies by implementation, but typically 32-bit
using uint_t = unsigned int;
///
/// \brief A signed integer type, with a size of at least 32-bits
using long_t = signed long;
///
/// \brief An unsigned integer type, with a size of at least 32-bits
using ulong_t = unsigned long;
///
/// \brief A signed integer type, with a size of 64-bits
using llong_t = signed long long;
///
/// \brief An unsigned integer type, with a size of 64-bits
using ullong_t = unsigned long long;
///
/// \brief A single-precision floating-point type, with a size of 32-bits
using float_t = float;
///
/// \brief A double-point type, with a size of 64-bits
using double_t = double;
/// @}
// Sized Arithmetic Types ==============================================================================================
///
/// \name Sized Integer Types
/// @{
///
/// \brief Signed 8-bit integer
using int8_t = schar_t;
///
/// \brief Signed 16-bit integer
using int16_t = short_t;
///
/// \brief Signed 32-bit integer
using int32_t = long_t;
///
/// \brief Signed signed 64-bit integer
using int64_t = llong_t;
/// @}
///
/// \name Sized Unsigned Integer Types
/// @{
///
/// \brief Unsigned 8-bit integer
using uint8_t = uchar_t;
///
/// \brief Unsigned 16-bit integer
using uint16_t = ushort_t;
///
/// \brief Unsigned 32-bit integer
using uint32_t = ulong_t;
///
/// \brief Unsigned 64-bit integer
using uint64_t = ullong_t;
/// @}
///
/// \name Sized Floating-Point Types
/// @{
///
/// \brief A single-precision floating-point scalar
using float32_t = float_t;
///
/// \brief A double-precision floating-point scalar
using float64_t = double_t;
/// @}
///
/// \name Special Types
/// @{
///
/// \brief Null Pointer Type
using nullptr_t = decltype(nullptr);
///
/// \brief Signed Integer Capable of Holding a Pointer to void
using intptr_t = intptr_t;
///
/// \brief Unsigned Integer Capable of Holding a Pointer to void
using uintptr_t = uintptr_t;
///
/// \brief Maximum Width Signed Integer Type
using intmax_t = __INTMAX_TYPE__;
///
/// \brief Maximum Width Unsigned Integer Type
using uintmax_t = __UINTMAX_TYPE__;
///
/// \brief Unsigned Integer Type Returned By `sizeof`, `sizeof...`, and `alignof`
using size_t = __SIZE_TYPE__;
///
/// \brief Signed Integer Type Returned by the Subtraction of two Pointers
using ptrdiff_t = __PTRDIFF_TYPE__;
/// @}
}
#endif // FENNEC_LANG_TYPES_H

View File

@@ -0,0 +1,81 @@
// =====================================================================================================================
// 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 <https://www.gnu.org/licenses/>.
// =====================================================================================================================
///
/// \file utility.h
/// \brief common utility functions related to the c++ language
///
///
/// \details
/// \author Medusa Slockbower
///
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
///
///
#ifndef UTILITY_H
#define UTILITY_H
#include <fennec/lang/type_transforms.h>
namespace fennec
{
///
///
/// \details
/// \tparam T base type of the object
/// \param x reference to the object
/// \returns
template<typename T> constexpr T&& forward(remove_reference_t<T>& x) noexcept { return x; }
///
///
/// \brief forwards reference types to extend their lifetime
///
/// \details
/// \tparam T base type of the object
/// \param x reference to the object
/// \returns
template<typename T> constexpr T&& forward(remove_reference_t<T>&& x) noexcept { return x; }
///
///
/// \brief produces an x-value type to indicate \p x may be "moved"
///
/// \details
/// \tparam T base type of the object
/// \param x object to be moved
/// \returns `static_cast<remove_reference_t<T>&&>(x)`
template<typename T> constexpr remove_reference_t<T>&& move(T&& x) noexcept { return static_cast<remove_reference_t<T>&&>(x); }
///
///
/// \brief produces an r-value type to indicate \p x may be "copied"
///
/// \details
/// \tparam T base type of the object
/// \param x object to be copied
/// \returns const r-value
template<typename T> constexpr const remove_reference_t<T>& copy(T&& x) noexcept { return x; }
}
#endif //UTILITY_H