brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · eb903db Raw
52 lines · plain
1//  Copyright John Maddock 2011-2021.2//  Use, modification and distribution are subject to the3//  Boost Software License, Version 1.0. (See accompanying file4//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)5 6#ifndef BOOST_MATH_TOOLS_IS_CONSTANT_EVALUATED_HPP7#define BOOST_MATH_TOOLS_IS_CONSTANT_EVALUATED_HPP8 9#include <boost/math/tools/config.hpp>10 11#ifdef __has_include12# if __has_include(<version>)13#  include <version>14#  ifdef __cpp_lib_is_constant_evaluated15#   include <type_traits>16#   define BOOST_MATH_HAS_IS_CONSTANT_EVALUATED17#  endif18# endif19#endif20 21#ifdef __has_builtin22#  if __has_builtin(__builtin_is_constant_evaluated) && !defined(BOOST_MATH_NO_CXX14_CONSTEXPR) && !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)23#    define BOOST_MATH_HAS_BUILTIN_IS_CONSTANT_EVALUATED24#  endif25#endif26//27// MSVC also supports __builtin_is_constant_evaluated if it's recent enough:28//29#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 192528326)30#  define BOOST_MATH_HAS_BUILTIN_IS_CONSTANT_EVALUATED31#endif32//33// As does GCC-9:34//35#if !defined(BOOST_MATH_NO_CXX14_CONSTEXPR) && (__GNUC__ >= 9) && !defined(BOOST_MATH_HAS_BUILTIN_IS_CONSTANT_EVALUATED)36#  define BOOST_MATH_HAS_BUILTIN_IS_CONSTANT_EVALUATED37#endif38 39#if defined(BOOST_MATH_HAS_IS_CONSTANT_EVALUATED) && !defined(BOOST_MATH_NO_CXX14_CONSTEXPR)40#  define BOOST_MATH_IS_CONSTANT_EVALUATED(x) std::is_constant_evaluated()41#elif defined(BOOST_MATH_HAS_BUILTIN_IS_CONSTANT_EVALUATED)42#  define BOOST_MATH_IS_CONSTANT_EVALUATED(x) __builtin_is_constant_evaluated()43#elif !defined(BOOST_MATH_NO_CXX14_CONSTEXPR) && (__GNUC__ >= 6)44#  define BOOST_MATH_IS_CONSTANT_EVALUATED(x) __builtin_constant_p(x)45#  define BOOST_MATH_USING_BUILTIN_CONSTANT_P46#else47#  define BOOST_MATH_IS_CONSTANT_EVALUATED(x) false48#  define BOOST_MATH_NO_CONSTEXPR_DETECTION49#endif50 51#endif // BOOST_MATH_TOOLS_IS_CONSTANT_EVALUATED_HPP52