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// constexpr byte& operator ^=(byte l, byte r) noexcept;
15
16
17constexpr std::byte test(std::byte b1, std::byte b2) {
18 std::byte bret = b1;
19 return bret ^= b2;
20 }
21
22
23int main(int, char**) {
24 std::byte b; // not constexpr, just used in noexcept check
25 constexpr std::byte b1{static_cast<std::byte>(1)};
26 constexpr std::byte b8{static_cast<std::byte>(8)};
27 constexpr std::byte b9{static_cast<std::byte>(9)};
28
29 static_assert(noexcept(b ^= b), "" );
30
31 static_assert(std::to_integer<int>(b: test(b1, b2: b8)) == 9, "");
32 static_assert(std::to_integer<int>(b: test(b1, b2: b9)) == 8, "");
33 static_assert(std::to_integer<int>(b: test(b1: b8, b2: b9)) == 1, "");
34
35 static_assert(std::to_integer<int>(b: test(b1: b8, b2: b1)) == 9, "");
36 static_assert(std::to_integer<int>(b: test(b1: b9, b2: b1)) == 8, "");
37 static_assert(std::to_integer<int>(b: test(b1: b9, b2: b8)) == 1, "");
38
39 return 0;
40}
41

source code of libcxx/test/std/language.support/support.types/byteops/xor.assign.pass.cpp