1// Copyright 2020-2023 Daniel Lemire
2// Copyright 2023 Matt Borland
3// Distributed under the Boost Software License, Version 1.0.
4// https://www.boost.org/LICENSE_1_0.txt
5//
6// Derivative of: https://github.com/fastfloat/fast_float
7
8#ifndef BOOST_CHARCONV_DETAIL_FASTFLOAT_CONSTEXPR_FEATURE_DETECT_HPP
9#define BOOST_CHARCONV_DETAIL_FASTFLOAT_CONSTEXPR_FEATURE_DETECT_HPP
10
11#ifdef __has_include
12#if __has_include(<version>)
13#include <version>
14#endif
15#endif
16
17// Testing for https://wg21.link/N3652, adopted in C++14
18#if __cpp_constexpr >= 201304
19#define BOOST_CHARCONV_FASTFLOAT_CONSTEXPR14 constexpr
20#else
21#define BOOST_CHARCONV_FASTFLOAT_CONSTEXPR14
22#endif
23
24#if defined(__cpp_lib_bit_cast) && __cpp_lib_bit_cast >= 201806L
25#define BOOST_CHARCONV_FASTFLOAT_HAS_BIT_CAST 1
26#else
27#define BOOST_CHARCONV_FASTFLOAT_HAS_BIT_CAST 0
28#endif
29
30#if defined(__cpp_lib_is_constant_evaluated) && __cpp_lib_is_constant_evaluated >= 201811L
31#define BOOST_CHARCONV_FASTFLOAT_HAS_IS_CONSTANT_EVALUATED 1
32#else
33#define BOOST_CHARCONV_FASTFLOAT_HAS_IS_CONSTANT_EVALUATED 0
34#endif
35
36// Testing for relevant C++20 constexpr library features
37#if BOOST_CHARCONV_FASTFLOAT_HAS_IS_CONSTANT_EVALUATED \
38 && BOOST_CHARCONV_FASTFLOAT_HAS_BIT_CAST \
39 && __cpp_lib_constexpr_algorithms >= 201806L /*For std::copy and std::fill*/
40#define BOOST_CHARCONV_FASTFLOAT_CONSTEXPR20 constexpr
41#define BOOST_CHARCONV_FASTFLOAT_IS_CONSTEXPR 1
42#else
43#define BOOST_CHARCONV_FASTFLOAT_CONSTEXPR20
44#define BOOST_CHARCONV_FASTFLOAT_IS_CONSTEXPR 0
45#endif
46
47#endif // BOOST_CHARCONV_FASTFLOAT_CONSTEXPR_FEATURE_DETECT_H
48

source code of boost/libs/charconv/include/boost/charconv/detail/fast_float/constexpr_feature_detect.hpp