placeholder_std_bind_test.cpp 841 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // placeholder_std_bind_test.cpp - std::bind with Boost's _1
  3. //
  4. // Copyright 2016 Peter Dimov
  5. //
  6. // Distributed under the Boost Software License, Version 1.0.
  7. // See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt
  9. //
  10. #include <boost/config.hpp>
  11. #if defined( BOOST_NO_CXX11_HDR_FUNCTIONAL )
  12. int main()
  13. {
  14. }
  15. #else
  16. #include <boost/bind.hpp>
  17. #include <boost/core/lightweight_test.hpp>
  18. #include <functional>
  19. namespace std
  20. {
  21. template<int N> struct is_placeholder< boost::arg<N> >: public integral_constant<int, N> {};
  22. } // namespace std
  23. int foo( int i )
  24. {
  25. return i;
  26. }
  27. int main()
  28. {
  29. BOOST_TEST_EQ( std::bind( foo, _1 )( 1 ), 1 );
  30. BOOST_TEST_EQ( std::bind( foo, _2 )( 1, 2 ), 2 );
  31. BOOST_TEST_EQ( std::bind( foo, _3 )( 1, 2, 3 ), 3 );
  32. return boost::report_errors();
  33. }
  34. #endif