bind_eq3_test.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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_eq3_test.cpp - function_equal with bind and weak_ptr
  10. //
  11. // Copyright (c) 2004, 2005, 2009 Peter Dimov
  12. //
  13. // Distributed under the Boost Software License, Version 1.0.
  14. // See 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/weak_ptr.hpp>
  20. #include <boost/detail/lightweight_test.hpp>
  21. int f( boost::weak_ptr<void> wp )
  22. {
  23. return wp.use_count();
  24. }
  25. template< class F > void test_self_equal( F f )
  26. {
  27. #ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
  28. using boost::function_equal;
  29. #endif
  30. BOOST_TEST( function_equal( f, f ) );
  31. }
  32. int main()
  33. {
  34. test_self_equal( boost::bind( f, _1 ) );
  35. test_self_equal( boost::bind( f, boost::weak_ptr<void>() ) );
  36. return boost::report_errors();
  37. }