bind_not_test.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*==============================================================================
  2. Copyright (c) 2005 Peter Dimov
  3. Copyright (c) 2005-2010 Joel de Guzman
  4. Copyright (c) 2010 Thomas Heller
  5. Distributed under the Boost Software License, Version 1.0. (See accompanying
  6. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. ==============================================================================*/
  8. #include <boost/config.hpp>
  9. #if defined(BOOST_MSVC)
  10. #pragma warning(disable: 4786) // identifier truncated in debug info
  11. #pragma warning(disable: 4710) // function not inlined
  12. #pragma warning(disable: 4711) // function selected for automatic inline expansion
  13. #pragma warning(disable: 4514) // unreferenced inline removed
  14. #endif
  15. #include <boost/phoenix/core.hpp>
  16. #include <boost/phoenix/bind.hpp>
  17. #include <boost/phoenix/operator.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 tester( 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. using boost::phoenix::bind;
  41. using boost::phoenix::placeholders::_1;
  42. tester( !bind( f, true ), 0, !f( true ) );
  43. tester( !bind( g, _1 ), 5, !g( 5 ) );
  44. tester( bind( f, !bind( f, true ) ), 0, f( !f( true ) ) );
  45. tester( bind( f, !bind( f, _1 ) ), true, f( !f( true ) ) );
  46. return boost::report_errors();
  47. }