Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
has_constexpr_bit_cast.hpp File Reference

Go to the source code of this file.

Macro Definition Documentation

◆ ARENE_HAS_CONSTEXPR_BIT_CAST

#define ARENE_HAS_CONSTEXPR_BIT_CAST

A platform support query indicating whether arene::base::bit_cast can be evaluated in a constant expression.

arene::base::bit_cast is constexpr only when the compiler provides __builtin_bit_cast . On toolchains without it (e.g. GCC 8), the implementation falls back to std::memcpy , which is not usable in a constant expression in C++14.

Usage:

#if ARENE_IS_ON(ARENE_HAS_CONSTEXPR_BIT_CAST)
constexpr auto value = arene::base::bit_cast<float>(pattern);
#endif
constexpr bit_cast_detail::do_bit_cast< To > bit_cast
Reinterpret the object representation of one type as that of another.

The value of this query is determined as follows, in order of precedence:

  1. If __builtin_bit_cast is defined, it is ARENE_ON_BY_DEFAULT
  1. Otherwise, it is ARENE_OFF_BY_DEFAULT

◆ ARENE_HAS_CONSTEXPR_BIT_CAST_I_

#define ARENE_HAS_CONSTEXPR_BIT_CAST_I_   ARENE_OFF_BY_DEFAULT