- Fixed up some style issues
- Added PLANNING.md
This commit is contained in:
51
include/fennec/lang/bits.h
Normal file
51
include/fennec/lang/bits.h
Normal file
@@ -0,0 +1,51 @@
|
||||
// =====================================================================================================================
|
||||
// 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_BITS_H
|
||||
#define FENNEC_LANG_BITS_H
|
||||
|
||||
#include <fennec/lang/intrinsics.h>
|
||||
#include <fennec/memory/memory.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
///
|
||||
/// \fn fennec::bit_cast(const FromT&)
|
||||
/// \brief
|
||||
/// \tparam ToT Type to cast to
|
||||
/// \tparam FromT Type of the value
|
||||
/// \param from Value to bit cast
|
||||
/// \return A value containing a bitwise copy of the input
|
||||
template<typename ToT, typename FromT> requires(sizeof(ToT) == sizeof(FromT))
|
||||
constexpr ToT bit_cast(const FromT& from)
|
||||
{
|
||||
if constexpr(FENNEC_HAS_BUILTIN_BIT_CAST)
|
||||
return FENNEC_BUILTIN_BIT_CAST(ToT, from);
|
||||
else
|
||||
{
|
||||
ToT to;
|
||||
memcpy(&to, &from, sizeof(ToT));
|
||||
return to;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_LANG_BITS_H
|
||||
@@ -30,7 +30,7 @@
|
||||
#ifndef FENNEC_LANG_FLOAT_H
|
||||
#define FENNEC_LANG_FLOAT_H
|
||||
|
||||
#include <fennec/memory/bits.h>
|
||||
#include <bits.h>
|
||||
|
||||
#define FLT_HAS_INFINITY 1
|
||||
#define FLT_HAS_QUIET_NAN 1
|
||||
|
||||
Reference in New Issue
Block a user