]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/language.support/support.types/byteops/or.assign.pass.cpp
Vendor import of libc++ trunk r300422:
[FreeBSD/FreeBSD.git] / test / std / language.support / support.types / byteops / or.assign.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 // constexpr byte& operator |=(byte l, byte r) noexcept;
19
20
21 constexpr std::byte test(std::byte b1, std::byte b2) {
22         std::byte bret = b1;
23         return bret |= b2;
24         }
25
26
27 int main () {
28         std::byte b;  // not constexpr, just used in noexcept check
29         constexpr std::byte b1{1};
30         constexpr std::byte b2{2};
31         constexpr std::byte b8{8};
32
33         static_assert(noexcept(b |= b), "" );
34
35         static_assert(std::to_integer<int>(test(b1, b2)) ==  3, "");
36         static_assert(std::to_integer<int>(test(b1, b8)) ==  9, "");
37         static_assert(std::to_integer<int>(test(b2, b8)) == 10, "");
38
39         static_assert(std::to_integer<int>(test(b2, b1)) ==  3, "");
40         static_assert(std::to_integer<int>(test(b8, b1)) ==  9, "");
41         static_assert(std::to_integer<int>(test(b8, b2)) == 10, "");
42
43 }