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 14 struct base { basebase15 base(int) {} basebase16 base(const base&) {} 17 virtual ~base(); 18 }; 19 ~base()20base::~base() {} 21 22 struct derived : virtual base { derivedderived23 derived() : base(1) {} derivedderived24 derived(const derived&) : base(1) {} operator ()derived25 int operator()(int i, void *) const { 26 return i; 27 } 28 ~derived(); 29 }; ~derived()30derived::~derived() {} 31 BOOST_HOF_TEST_CASE()32BOOST_HOF_TEST_CASE() 33 { 34 BOOST_HOF_TEST_CHECK(boost::hof::flip(derived())(nullptr, 2) == 2); 35 BOOST_HOF_TEST_CHECK(boost::hof::rotate(derived())(nullptr, 2) == 2); 36 BOOST_HOF_TEST_CHECK((2 | boost::hof::pipable(derived())(nullptr)) == 2); 37 } 38