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 #include <cstddef>
10 #include <test_macros.h>
11
12 // UNSUPPORTED: c++03, c++11, c++14
13
14 // template <class IntegerType>
15 // constexpr byte operator <<(byte b, IntegerType shift) noexcept;
16 // These functions shall not participate in overload resolution unless
17 // is_integral_v<IntegerType> is true.
18
19
test(std::byte b)20 constexpr std::byte test(std::byte b) {
21 return b <<= 2;
22 }
23
24
main(int,char **)25 int main(int, char**) {
26 constexpr std::byte b100{static_cast<std::byte>(100)};
27 constexpr std::byte b115{static_cast<std::byte>(115)};
28
29 static_assert(noexcept(b100 << 2), "" );
30
31 static_assert(std::to_integer<int>(b100 >> 1) == 50, "");
32 static_assert(std::to_integer<int>(b100 >> 2) == 25, "");
33 static_assert(std::to_integer<int>(b115 >> 3) == 14, "");
34 static_assert(std::to_integer<int>(b115 >> 6) == 1, "");
35
36
37 return 0;
38 }
39