tap.cpp 814 B

12345678910111213141516171819202122232425
  1. /*=============================================================================
  2. Copyright (c) 2017 Paul Fultz II
  3. tap.cpp
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. ==============================================================================*/
  7. #include <boost/hof/tap.hpp>
  8. #include "test.hpp"
  9. struct sum_f
  10. {
  11. template<class T, class U>
  12. constexpr T operator()(T x, U y) const
  13. {
  14. return x+y;
  15. }
  16. };
  17. static constexpr boost::hof::pipable_adaptor<sum_f> sum = {};
  18. // TODO: Test constexpr
  19. BOOST_HOF_TEST_CASE()
  20. {
  21. BOOST_HOF_TEST_CHECK(3 == (1 | sum(2)));
  22. BOOST_HOF_TEST_CHECK(5 == (1 | sum(2) | boost::hof::tap([](int i) { BOOST_HOF_TEST_CHECK(3 == i); }) | sum(2)));
  23. }