Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
has_constexpr_bit_cast.hpp
Go to the documentation of this file.
1
// Copyright 2026, Toyota Motor Corporation
2
//
3
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5
#
ifndef
INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_COMPILER_SUPPORT_PLATFORM_QUERIES_HAS_CONSTEXPR_BIT_CAST_HPP_
6
#
define
INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_COMPILER_SUPPORT_PLATFORM_QUERIES_HAS_CONSTEXPR_BIT_CAST_HPP_
7
8
// IWYU pragma: private, include "arene/base/compiler_support/platform_queries.hpp"
9
// IWYU pragma: friend "arene/base/compiler_support/platform_queries/.*"
10
11
// parasoft-begin-suppress AUTOSAR-A16_2_2-a-2 "Arene Base aggregate headers permitted by A16-2-2 Permit #1"
12
#
include
"arene/base/compiler_support/platform_queries/compiler_info.hpp"
// IWYU pragma: keep
13
#
include
"arene/base/compiler_support/platform_queries/has_builtin.hpp"
14
#
include
"arene/base/compiler_support/preprocessor.hpp"
15
// parasoft-end-suppress AUTOSAR-A16_2_2-a-2
16
17
// NOLINTBEGIN(cppcoreguidelines-macro-usage) Explicitly providing compiler support macro functions
18
// parasoft-begin-suppress AUTOSAR-A16_0_1-d-2 "Conditional defines permitted by A16-0-1 Permit #2"
19
// parasoft-begin-suppress AUTOSAR-A16_0_1-a-2 "Conditional defines permitted by A16-0-1 Permit #2"
20
21
/// @def ARENE_HAS_CONSTEXPR_BIT_CAST
22
/// @brief A platform support query indicating whether @c arene::base::bit_cast
23
/// can be evaluated in a constant expression.
24
///
25
/// @c arene::base::bit_cast is @c constexpr only when the compiler provides
26
/// @c __builtin_bit_cast . On toolchains without it (e.g. GCC 8), the
27
/// implementation falls back to @c std::memcpy , which is not usable in a
28
/// constant expression in C++14.
29
///
30
/// Usage:
31
/// @code{c++}
32
/// #if ARENE_IS_ON(ARENE_HAS_CONSTEXPR_BIT_CAST)
33
/// constexpr auto value = arene::base::bit_cast<float>(pattern);
34
/// #endif
35
/// @endcode
36
///
37
/// The value of this query is determined as follows, in order of precedence:
38
/// 1. If @c __builtin_bit_cast is defined, it is @c ARENE_ON_BY_DEFAULT
39
/// 1. Otherwise, it is @c ARENE_OFF_BY_DEFAULT
40
41
// parasoft-begin-suppress AUTOSAR-M16_0_7-a-2 "False positive: not used as a macro"
42
#
if
ARENE_HAS_BUILTIN
(
__builtin_bit_cast
)
43
// parasoft-end-suppress AUTOSAR-M16_0_7-a-2
44
#
define
ARENE_HAS_CONSTEXPR_BIT_CAST_I_
ARENE_ON_BY_DEFAULT
45
#
else
46
#
define
ARENE_HAS_CONSTEXPR_BIT_CAST_I_
ARENE_OFF_BY_DEFAULT
47
#
endif
48
49
#
ifdef
ARENE_DOC_GENERATION_RUNNING
// make this appear when running doxygen, as it won't otherwise.
50
#
ifndef
ARENE_HAS_CONSTEXPR_BIT_CAST
51
#
define
ARENE_HAS_CONSTEXPR_BIT_CAST
52
#
endif
53
#
endif
54
55
// NOLINTEND(cppcoreguidelines-macro-usage)
56
// parasoft-end-suppress AUTOSAR-A16_0_1-d-2
57
// parasoft-end-suppress AUTOSAR-A16_0_1-a-2
58
59
#
endif
// INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_COMPILER_SUPPORT_PLATFORM_QUERIES_HAS_CONSTEXPR_BIT_CAST_HPP_
arene
base
compiler_support
platform_queries
has_constexpr_bit_cast.hpp
Generated by
1.13.2