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