| 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 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 |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS |
| 10 | |
| 11 | // <functional> |
| 12 | |
| 13 | // bit_or |
| 14 | |
| 15 | #include <functional> |
| 16 | #include <type_traits> |
| 17 | #include <cassert> |
| 18 | |
| 19 | #include "test_macros.h" |
| 20 | |
| 21 | int main(int, char**) |
| 22 | { |
| 23 | typedef std::bit_or<int> F; |
| 24 | const F f = 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), "" ); |
| 29 | #endif |
| 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); |
| 35 | #if TEST_STD_VER > 11 |
| 36 | typedef std::bit_or<> F2; |
| 37 | const F2 f2 = F2(); |
| 38 | assert(f2(0xEA95, 0xEA95) == 0xEA95); |
| 39 | assert(f2(0xEA95L, 0xEA95) == 0xEA95); |
| 40 | assert(f2(0xEA95, 0xEA95L) == 0xEA95); |
| 41 | |
| 42 | assert(f2(0xEA95, 0x58D3) == 0xFAD7); |
| 43 | assert(f2(0xEA95L, 0x58D3) == 0xFAD7); |
| 44 | assert(f2(0xEA95, 0x58D3L) == 0xFAD7); |
| 45 | |
| 46 | assert(f2(0x58D3, 0xEA95) == 0xFAD7); |
| 47 | assert(f2(0x58D3L, 0xEA95) == 0xFAD7); |
| 48 | assert(f2(0x58D3, 0xEA95L) == 0xFAD7); |
| 49 | |
| 50 | assert(f2(0x58D3, 0) == 0x58D3); |
| 51 | assert(f2(0x58D3L, 0) == 0x58D3); |
| 52 | assert(f2(0x58D3, 0L) == 0x58D3); |
| 53 | |
| 54 | assert(f2(0xFFFF, 0x58D3) == 0xFFFF); |
| 55 | assert(f2(0xFFFFL, 0x58D3) == 0xFFFF); |
| 56 | assert(f2(0xFFFF, 0x58D3L) == 0xFFFF); |
| 57 | |
| 58 | constexpr int foo = std::bit_or<int> () (0x58D3, 0xEA95); |
| 59 | static_assert ( foo == 0xFAD7, "" ); |
| 60 | |
| 61 | constexpr int bar = std::bit_or<> () (0x58D3L, 0xEA95); |
| 62 | static_assert ( bar == 0xFAD7, "" ); |
| 63 | #endif |
| 64 | |
| 65 | return 0; |
| 66 | } |
| 67 | |