]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/language.support/support.types/byteops/lshift.pass.cpp
Vendor import of libc++ trunk r300422:
[FreeBSD/FreeBSD.git] / test / std / language.support / support.types / byteops / lshift.pass.cpp
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include <cstddef>
11 #include <test_macros.h>
12
13 // UNSUPPORTED: c++98, c++03, c++11, c++14
14 // The following compilers don't like "std::byte b1{1}"
15 // UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
16 // UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
17
18 // template <class IntegerType>
19 //    constexpr byte operator <<(byte b, IntegerType shift) noexcept;
20 // These functions shall not participate in overload resolution unless 
21 //   is_integral_v<IntegerType> is true.
22
23 int main () {
24         constexpr std::byte b1{1};
25         constexpr std::byte b3{3};
26         
27         static_assert(noexcept(b3 << 2), "" );
28
29         static_assert(std::to_integer<int>(b1 << 1) ==   2, "");
30         static_assert(std::to_integer<int>(b1 << 2) ==   4, "");
31         static_assert(std::to_integer<int>(b3 << 4) ==  48, "");
32         static_assert(std::to_integer<int>(b3 << 6) == 192, "");        
33 }