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// UNSUPPORTED: c++03, c++11
10// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
11
12// <functional>
13
14// bit_not
15
16#include <functional>
17#include <type_traits>
18#include <cassert>
19
20#include "test_macros.h"
21
22int main(int, char**)
23{
24 typedef std::bit_not<int> F;
25 const F f = F();
26#if TEST_STD_VER <= 17
27 static_assert((std::is_same<F::argument_type, int>::value), "" );
28 static_assert((std::is_same<F::result_type, int>::value), "" );
29#endif
30 assert((f(0xEA95) & 0xFFFF ) == 0x156A);
31 assert((f(0x58D3) & 0xFFFF ) == 0xA72C);
32 assert((f(0) & 0xFFFF ) == 0xFFFF);
33 assert((f(0xFFFF) & 0xFFFF ) == 0);
34
35 typedef std::bit_not<> F2;
36 const F2 f2 = F2();
37 assert((f2(0xEA95) & 0xFFFF ) == 0x156A);
38 assert((f2(0xEA95L) & 0xFFFF ) == 0x156A);
39 assert((f2(0x58D3) & 0xFFFF ) == 0xA72C);
40 assert((f2(0x58D3L) & 0xFFFF ) == 0xA72C);
41 assert((f2(0) & 0xFFFF ) == 0xFFFF);
42 assert((f2(0L) & 0xFFFF ) == 0xFFFF);
43 assert((f2(0xFFFF) & 0xFFFF ) == 0);
44 assert((f2(0xFFFFL) & 0xFFFF ) == 0);
45
46 constexpr int foo = std::bit_not<int> () (0xEA95) & 0xFFFF;
47 static_assert ( foo == 0x156A, "" );
48
49 constexpr int bar = std::bit_not<> () (0xEA95) & 0xFFFF;
50 static_assert ( bar == 0x156A, "" );
51
52 return 0;
53}
54

source code of libcxx/test/std/utilities/function.objects/bitwise.operations/bit_not.pass.cpp