1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
16 #include <type_traits>
19 #include "test_macros.h"
24 typedef std::bit_xor
<int> F
;
26 #if TEST_STD_VER <= 17
27 static_assert((std::is_same
<int, F::first_argument_type
>::value
), "" );
28 static_assert((std::is_same
<int, F::second_argument_type
>::value
), "" );
29 static_assert((std::is_same
<int, F::result_type
>::value
), "" );
31 assert(f(0xEA95, 0xEA95) == 0);
32 assert(f(0xEA95, 0x58D3) == 0xB246);
33 assert(f(0x58D3, 0xEA95) == 0xB246);
34 assert(f(0x58D3, 0) == 0x58D3);
35 assert(f(0xFFFF, 0x58D3) == 0xA72C);
39 typedef std::bit_xor
<> F2
;
41 assert(f(0xEA95, 0xEA95) == 0);
42 assert(f(0xEA95L
, 0xEA95) == 0);
43 assert(f(0xEA95, 0xEA95L
) == 0);
45 assert(f(0xEA95, 0x58D3) == 0xB246);
46 assert(f(0xEA95L
, 0x58D3) == 0xB246);
47 assert(f(0xEA95, 0x58D3L
) == 0xB246);
49 assert(f(0x58D3, 0xEA95) == 0xB246);
50 assert(f(0x58D3L
, 0xEA95) == 0xB246);
51 assert(f(0x58D3, 0xEA95L
) == 0xB246);
53 assert(f(0x58D3, 0) == 0x58D3);
54 assert(f(0x58D3L
, 0) == 0x58D3);
55 assert(f(0x58D3, 0L) == 0x58D3);
57 assert(f(0xFFFF, 0x58D3) == 0xA72C);
58 assert(f(0xFFFFL
, 0x58D3) == 0xA72C);
59 assert(f(0xFFFF, 0x58D3L
) == 0xA72C);
61 constexpr int foo
= std::bit_xor
<int> () (0x58D3, 0xEA95);
62 static_assert ( foo
== 0xB246, "" );
64 constexpr int bar
= std::bit_xor
<> () (0x58D3L
, 0xEA95);
65 static_assert ( bar
== 0xB246, "" );