bind_not_test.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include <boost/config.hpp>
  2. #if defined(BOOST_MSVC)
  3. #pragma warning(disable: 4786) // identifier truncated in debug info
  4. #pragma warning(disable: 4710) // function not inlined
  5. #pragma warning(disable: 4711) // function selected for automatic inline expansion
  6. #pragma warning(disable: 4514) // unreferenced inline removed
  7. #endif
  8. //
  9. // bind_not_test.cpp - operator!
  10. //
  11. // Copyright (c) 2005 Peter Dimov
  12. //
  13. // Distributed under the Boost Software License, Version 1.0. (See
  14. // accompanying file LICENSE_1_0.txt or copy at
  15. // http://www.boost.org/LICENSE_1_0.txt)
  16. //
  17. #include <boost/bind.hpp>
  18. #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
  19. #pragma warning(push, 3)
  20. #endif
  21. #include <iostream>
  22. #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
  23. #pragma warning(pop)
  24. #endif
  25. #include <boost/detail/lightweight_test.hpp>
  26. template<class F, class A1, class R> void test( F f, A1 a1, R r )
  27. {
  28. BOOST_TEST( f(a1) == r );
  29. }
  30. bool f( bool v )
  31. {
  32. return v;
  33. }
  34. int g( int v )
  35. {
  36. return v;
  37. }
  38. int main()
  39. {
  40. test( !boost::bind( f, true ), 0, !f( true ) );
  41. test( !boost::bind( g, _1 ), 5, !g( 5 ) );
  42. test( boost::bind( f, !boost::bind( f, true ) ), 0, f( !f( true ) ) );
  43. test( boost::bind( f, !boost::bind( f, _1 ) ), true, f( !f( true ) ) );
  44. return boost::report_errors();
  45. }