[clang] Add tracking source deduction guide for the explicitly-written
[llvm-project.git] / libcxx / test / std / numerics / bit / bit.pow.two / bit_ceil.verify.cpp
blobd37de690a48dbabef854873761269ed391aa692c
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
11 // template <class T>
12 // constexpr T bit_ceil(T x) noexcept;
14 // Remarks: This function shall not participate in overload resolution unless
15 // T is an unsigned integer type
17 #include <bit>
18 #include <cassert>
19 #include <cstddef>
20 #include <cstdint>
21 #include <limits>
23 class A{};
24 enum E1 : unsigned char { rEd };
25 enum class E2 : unsigned char { red };
27 template <typename T>
28 constexpr bool toobig()
30 return 0 == std::bit_ceil(std::numeric_limits<T>::max());
33 int main(int, char**)
35 // Make sure we generate a compile-time error for UB
36 static_assert(toobig<unsigned char>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
37 static_assert(toobig<unsigned short>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
38 static_assert(toobig<unsigned>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
39 static_assert(toobig<unsigned long>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
40 static_assert(toobig<unsigned long long>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
42 static_assert(toobig<std::uint8_t>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
43 static_assert(toobig<std::uint16_t>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
44 static_assert(toobig<std::uint32_t>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
45 static_assert(toobig<std::uint64_t>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
46 static_assert(toobig<std::size_t>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
47 static_assert(toobig<std::uintmax_t>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
48 static_assert(toobig<std::uintptr_t>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
50 return 0;