lazy_argument_tests.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. ////////////////////////////////////////////////////////////////////////////
  2. // lazy_argument_tests.cpp
  3. //
  4. // lazy argument tests passing lazy function as argument.
  5. //
  6. ////////////////////////////////////////////////////////////////////////////
  7. /*=============================================================================
  8. Copyright (c) 2001-2007 Joel de Guzman
  9. Copyright (c) 2015 John Fletcher
  10. Distributed under the Boost Software License, Version 1.0. (See accompanying
  11. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  12. ==============================================================================*/
  13. #include <boost/phoenix/core/limits.hpp>
  14. #include <boost/detail/lightweight_test.hpp>
  15. #include <boost/phoenix/core.hpp>
  16. #include <boost/phoenix/function.hpp>
  17. namespace example {
  18. struct G {
  19. template <typename Sig>
  20. struct result;
  21. template <typename This, typename A0>
  22. struct result<This(A0)>
  23. : boost::remove_reference<A0>
  24. {};
  25. template <typename T>
  26. T operator()(T t) const { return ++t; }
  27. };
  28. }
  29. typedef boost::phoenix::function<example::G> GG;
  30. boost::phoenix::function<example::G> gg;
  31. template <typename F,typename T>
  32. T h(F f, T const& t)
  33. {
  34. return f(t)();
  35. }
  36. int main()
  37. {
  38. BOOST_TEST( h(gg,1) == 2);
  39. BOOST_TEST(( h<GG,int>(gg,1) == 2));
  40. return boost::report_errors();
  41. }