File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -3999,13 +3999,18 @@ enum class endian
3999
3999
};
4000
4000
#endif
4001
4001
4002
- #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED)
4002
+ #ifndef _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
4003
+ #if _LIBCPP_STD_VER > 17
4003
4004
_LIBCPP_INLINE_VISIBILITY
4004
4005
inline constexpr bool is_constant_evaluated () noexcept {
4005
4006
return __builtin_is_constant_evaluated ();
4006
4007
}
4007
4008
#endif
4008
4009
4010
+ _LIBCPP_CONSTEXPR bool __libcpp_is_constant_evaluated () _NOEXCEPT { return __builtin_is_constant_evaluated (); }
4011
+ #else
4012
+ _LIBCPP_CONSTEXPR bool __libcpp_is_constant_evaluated () _NOEXCEPT { return false ; }
4013
+ #endif
4009
4014
4010
4015
template <class _CharT >
4011
4016
using _IsCharLikeType = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >;
Original file line number Diff line number Diff line change
1
+ // ===----------------------------------------------------------------------===//
2
+ //
3
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
+ // See https://llvm.org/LICENSE.txt for license information.
5
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
+ //
7
+ // ===----------------------------------------------------------------------===//
8
+ //
9
+
10
+ // <type_traits>
11
+
12
+ // __libcpp_is_constant_evaluated()
13
+
14
+ // returns false when there's no constant evaluation support from the compiler.
15
+ // as well as when called not in a constexpr context
16
+
17
+ #include < type_traits>
18
+ #include < cassert>
19
+
20
+ #include " test_macros.h"
21
+
22
+ int main (int , char **) {
23
+ ASSERT_SAME_TYPE (decltype (std::__libcpp_is_constant_evaluated ()), bool );
24
+ ASSERT_NOEXCEPT (std::__libcpp_is_constant_evaluated ());
25
+
26
+ #if !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED) && !defined(_LIBCPP_CXX03_LANG)
27
+ static_assert (std::__libcpp_is_constant_evaluated (), " " );
28
+ #endif
29
+
30
+ bool p = std::__libcpp_is_constant_evaluated ();
31
+ assert (!p);
32
+
33
+ return 0 ;
34
+ }
You can’t perform that action at this time.
0 commit comments