virtual_base.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*=============================================================================
  2. Copyright (c) 2017 Paul Fultz II
  3. virtual_base.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/flip.hpp>
  8. #include <boost/hof/proj.hpp>
  9. #include <boost/hof/construct.hpp>
  10. #include <boost/hof/pipable.hpp>
  11. #include <boost/hof/rotate.hpp>
  12. #include "test.hpp"
  13. struct base {
  14. base(int) {}
  15. base(const base&) {}
  16. virtual ~base();
  17. };
  18. base::~base() {}
  19. struct derived : virtual base {
  20. derived() : base(1) {}
  21. derived(const derived&) : base(1) {}
  22. int operator()(int i, void *) const {
  23. return i;
  24. }
  25. ~derived();
  26. };
  27. derived::~derived() {}
  28. BOOST_HOF_TEST_CASE()
  29. {
  30. BOOST_HOF_TEST_CHECK(boost::hof::flip(derived())(nullptr, 2) == 2);
  31. BOOST_HOF_TEST_CHECK(boost::hof::rotate(derived())(nullptr, 2) == 2);
  32. BOOST_HOF_TEST_CHECK((2 | boost::hof::pipable(derived())(nullptr)) == 2);
  33. }