1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
15 #include <type_traits>
18 #include "test_macros.h"
23 typedef std::bit_xor<int> 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);
36 typedef std::bit_xor<> F2;
38 assert(f(0xEA95, 0xEA95) == 0);
39 assert(f(0xEA95L, 0xEA95) == 0);
40 assert(f(0xEA95, 0xEA95L) == 0);
42 assert(f(0xEA95, 0x58D3) == 0xB246);
43 assert(f(0xEA95L, 0x58D3) == 0xB246);
44 assert(f(0xEA95, 0x58D3L) == 0xB246);
46 assert(f(0x58D3, 0xEA95) == 0xB246);
47 assert(f(0x58D3L, 0xEA95) == 0xB246);
48 assert(f(0x58D3, 0xEA95L) == 0xB246);
50 assert(f(0x58D3, 0) == 0x58D3);
51 assert(f(0x58D3L, 0) == 0x58D3);
52 assert(f(0x58D3, 0L) == 0x58D3);
54 assert(f(0xFFFF, 0x58D3) == 0xA72C);
55 assert(f(0xFFFFL, 0x58D3) == 0xA72C);
56 assert(f(0xFFFF, 0x58D3L) == 0xA72C);
58 constexpr int foo = std::bit_xor<int> () (0x58D3, 0xEA95);
59 static_assert ( foo == 0xB246, "" );
61 constexpr int bar = std::bit_xor<> () (0x58D3L, 0xEA95);
62 static_assert ( bar == 0xB246, "" );