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 // <functional>
11
12 // bit_xor
13
14 #include <functional>
15 #include <type_traits>
16 #include <cassert>
17
18 #include "test_macros.h"
19
main()20 int main()
21 {
22 {
23 typedef std::bit_xor<int> F;
24 const F f = F();
25 static_assert((std::is_same<int, F::first_argument_type>::value), "" );
26 static_assert((std::is_same<int, F::second_argument_type>::value), "" );
27 static_assert((std::is_same<int, F::result_type>::value), "" );
28 assert(f(0xEA95, 0xEA95) == 0);
29 assert(f(0xEA95, 0x58D3) == 0xB246);
30 assert(f(0x58D3, 0xEA95) == 0xB246);
31 assert(f(0x58D3, 0) == 0x58D3);
32 assert(f(0xFFFF, 0x58D3) == 0xA72C);
33 }
34 #if TEST_STD_VER > 11
35 {
36 typedef std::bit_xor<> F2;
37 const F2 f = F2();
38 assert(f(0xEA95, 0xEA95) == 0);
39 assert(f(0xEA95L, 0xEA95) == 0);
40 assert(f(0xEA95, 0xEA95L) == 0);
41
42 assert(f(0xEA95, 0x58D3) == 0xB246);
43 assert(f(0xEA95L, 0x58D3) == 0xB246);
44 assert(f(0xEA95, 0x58D3L) == 0xB246);
45
46 assert(f(0x58D3, 0xEA95) == 0xB246);
47 assert(f(0x58D3L, 0xEA95) == 0xB246);
48 assert(f(0x58D3, 0xEA95L) == 0xB246);
49
50 assert(f(0x58D3, 0) == 0x58D3);
51 assert(f(0x58D3L, 0) == 0x58D3);
52 assert(f(0x58D3, 0L) == 0x58D3);
53
54 assert(f(0xFFFF, 0x58D3) == 0xA72C);
55 assert(f(0xFFFFL, 0x58D3) == 0xA72C);
56 assert(f(0xFFFF, 0x58D3L) == 0xA72C);
57
58 constexpr int foo = std::bit_xor<int> () (0x58D3, 0xEA95);
59 static_assert ( foo == 0xB246, "" );
60
61 constexpr int bar = std::bit_xor<> () (0x58D3L, 0xEA95);
62 static_assert ( bar == 0xB246, "" );
63 }
64 #endif
65 }
66