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
22int 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_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 }
35

source code of libcxx/test/libcxx/type_traits/is_constant_evaluated.pass.cpp