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_not 13 14#include <functional> 15#include <type_traits> 16#include <cassert> 17 18int main() 19{ 20#if _LIBCPP_STD_VER > 11 21 typedef std::bit_not<int> F; 22 const F f = F(); 23 static_assert((std::is_same<F::argument_type, int>::value), "" ); 24 static_assert((std::is_same<F::result_type, int>::value), "" ); 25 assert((f(0xEA95) & 0xFFFF ) == 0x156A); 26 assert((f(0x58D3) & 0xFFFF ) == 0xA72C); 27 assert((f(0) & 0xFFFF ) == 0xFFFF); 28 assert((f(0xFFFF) & 0xFFFF ) == 0); 29 30 typedef std::bit_not<> F2; 31 const F2 f2 = F2(); 32 assert((f2(0xEA95) & 0xFFFF ) == 0x156A); 33 assert((f2(0xEA95L) & 0xFFFF ) == 0x156A); 34 assert((f2(0x58D3) & 0xFFFF ) == 0xA72C); 35 assert((f2(0x58D3L) & 0xFFFF ) == 0xA72C); 36 assert((f2(0) & 0xFFFF ) == 0xFFFF); 37 assert((f2(0L) & 0xFFFF ) == 0xFFFF); 38 assert((f2(0xFFFF) & 0xFFFF ) == 0); 39 assert((f2(0xFFFFL) & 0xFFFF ) == 0); 40 41 constexpr int foo = std::bit_not<int> () (0xEA95) & 0xFFFF; 42 static_assert ( foo == 0x156A, "" ); 43 44 constexpr int bar = std::bit_not<> () (0xEA95) & 0xFFFF; 45 static_assert ( bar == 0x156A, "" ); 46#endif 47} 48