82 lines
2.1 KiB
C++
82 lines
2.1 KiB
C++
// =====================================================================================================================
|
|
// 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
|