1// constexpr test for boost/core/bit.hpp (bit_cast)
2//
3// Copyright 2023 Peter Dimov
4// Distributed under the Boost Software License, Version 1.0.
5// https://www.boost.org/LICENSE_1_0.txt
6
7#include <boost/core/bit.hpp>
8#include <boost/cstdint.hpp>
9
10#include <boost/config.hpp>
11#include <boost/config/pragma_message.hpp>
12
13#if defined(BOOST_NO_CXX11_CONSTEXPR)
14
15BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined" )
16
17#elif !defined(BOOST_CORE_HAS_BUILTIN_BIT_CAST)
18
19BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_CORE_HAS_BUILTIN_BIT_CAST is not defined" )
20
21#else
22
23#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
24
25STATIC_ASSERT( boost::core::bit_cast<boost::uint32_t>( 1.0f ) == 0x3F800000u );
26STATIC_ASSERT( boost::core::bit_cast<boost::uint64_t>( 1.0 ) == 0x3FF0000000000000ull );
27
28#endif
29

source code of boost/libs/core/test/bit_cast_test_cx.cpp