bind_eq2_test.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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_eq2_test.cpp - boost::bind equality operator
  10. //
  11. // Copyright (c) 2004, 2005, 2009 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. #include <boost/function_equal.hpp>
  19. #include <boost/detail/lightweight_test.hpp>
  20. void f( int )
  21. {
  22. }
  23. int g( int i )
  24. {
  25. return i + 5;
  26. }
  27. template< class F > void test_self_equal( F f )
  28. {
  29. #ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
  30. using boost::function_equal;
  31. #endif
  32. BOOST_TEST( function_equal( f, f ) );
  33. }
  34. int main()
  35. {
  36. test_self_equal( boost::bind( f, _1 ) );
  37. test_self_equal( boost::bind( g, _1 ) );
  38. test_self_equal( boost::bind( f, boost::bind( g, _1 ) ) );
  39. return boost::report_errors();
  40. }