Skip to content

Commit

Permalink
COMP: Switched to __cpp_lib_bit_cast to detect std::bit_cast availabi…
Browse files Browse the repository at this point in the history
…lity (#1057)

* Also moved namespace alias to inside the relevant function to reduce namespace pollution

Signed-off-by: Jared Duffey <[email protected]>
  • Loading branch information
JDuffeyBQ authored Aug 27, 2024
1 parent 532ad79 commit fb0dc0e
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/simplnx/Common/TypesUtility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,17 @@
#include "simplnx/Common/TypeTraits.hpp"
#include "simplnx/Common/Types.hpp"

#if defined(__clang__) && defined(__clang_major__) && defined(__APPLE__)
#if __clang_major__ > 14
#include <bit>
namespace bs = std;
#else
#include "Bit.hpp"
namespace bs = nx::core;
#endif
#else
#include <bit>
namespace bs = std;
#endif

#include <optional>
#include <stdexcept>
#include <vector>

#include <version>
#if __cpp_lib_bit_cast
#include <bit>
#else
#include "simplnx/Common/Bit.hpp"
#endif

namespace nx::core
{
/**
Expand All @@ -31,6 +25,12 @@ namespace nx::core
template <typename T>
constexpr T GetMudflap() noexcept
{
#if __cpp_lib_bit_cast
namespace bs = std;
#else
namespace bs = nx::core;
#endif

if constexpr(sizeof(T) == 1)
{
return bs::bit_cast<T>(static_cast<uint8>(0xAB));
Expand Down

0 comments on commit fb0dc0e

Please sign in to comment.