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"
23 typedef std::bit_or
<int> F
;
25 #if TEST_STD_VER <= 17
26 static_assert((std::is_same
<int, F::first_argument_type
>::value
), "" );
27 static_assert((std::is_same
<int, F::second_argument_type
>::value
), "" );
28 static_assert((std::is_same
<int, F::result_type
>::value
), "" );
30 assert(f(0xEA95, 0xEA95) == 0xEA95);
31 assert(f(0xEA95, 0x58D3) == 0xFAD7);
32 assert(f(0x58D3, 0xEA95) == 0xFAD7);
33 assert(f(0x58D3, 0) == 0x58D3);
34 assert(f(0xFFFF, 0x58D3) == 0xFFFF);
36 typedef std::bit_or
<> F2
;
38 assert(f2(0xEA95, 0xEA95) == 0xEA95);
39 assert(f2(0xEA95L
, 0xEA95) == 0xEA95);
40 assert(f2(0xEA95, 0xEA95L
) == 0xEA95);
42 assert(f2(0xEA95, 0x58D3) == 0xFAD7);
43 assert(f2(0xEA95L
, 0x58D3) == 0xFAD7);
44 assert(f2(0xEA95, 0x58D3L
) == 0xFAD7);
46 assert(f2(0x58D3, 0xEA95) == 0xFAD7);
47 assert(f2(0x58D3L
, 0xEA95) == 0xFAD7);
48 assert(f2(0x58D3, 0xEA95L
) == 0xFAD7);
50 assert(f2(0x58D3, 0) == 0x58D3);
51 assert(f2(0x58D3L
, 0) == 0x58D3);
52 assert(f2(0x58D3, 0L) == 0x58D3);
54 assert(f2(0xFFFF, 0x58D3) == 0xFFFF);
55 assert(f2(0xFFFFL
, 0x58D3) == 0xFFFF);
56 assert(f2(0xFFFF, 0x58D3L
) == 0xFFFF);
58 constexpr int foo
= std::bit_or
<int> () (0x58D3, 0xEA95);
59 static_assert ( foo
== 0xFAD7, "" );
61 constexpr int bar
= std::bit_or
<> () (0x58D3L
, 0xEA95);
62 static_assert ( bar
== 0xFAD7, "" );