1 /* Copyright 2016-2017 Joaquin M Lopez Munoz.
2 * Distributed under the Boost Software License, Version 1.0.
3 * (See accompanying file LICENSE_1_0.txt or copy at
4 * http://www.boost.org/LICENSE_1_0.txt)
6 * See http://www.boost.org/libs/poly_collection for library home page.
9 #ifndef BOOST_POLY_COLLECTION_TEST_BASE_TYPES_HPP
10 #define BOOST_POLY_COLLECTION_TEST_BASE_TYPES_HPP
16 #include <boost/poly_collection/base_collection.hpp>
22 virtual ~base()=default;
23 virtual int operator()(int)const=0;
26 struct derived1 final:base
28 derived1(int n):n{n}{}
29 derived1(derived1&&)=default;
30 derived1(const derived1&)=delete;
31 derived1& operator=(derived1&&)=default;
32 derived1& operator=(const derived1&)=delete;
33 virtual int operator()(int)const{return n;}
34 bool operator==(const derived1& x)const{return n==x.n;}
40 derived2(int n):n{n}{}
41 derived2(derived2&&)=default;
42 derived2& operator=(derived2&&)=delete;
43 virtual int operator()(int x)const{return x*n;}
44 bool operator==(const derived2& x)const{return n==x.n;}
51 derived3(int n):n{n}{}
52 virtual int operator()(int x)const{return x*x*n;}
58 virtual ~another_base()=default;
62 struct derived4:another_base,derived3
64 using derived3::derived3;
65 virtual int operator()(int x)const{return -(this->derived3::operator()(x));}
66 bool operator==(const derived4& x)const{return n==x.n;}
69 struct derived5:base,another_base
71 derived5(int n):n{n}{}
72 virtual int operator()(int x)const{return x*x*x*n;}
76 using collection=boost::base_collection<base>;
89 int operator()(const F& f)const{return f(1);}
92 } /* namespace base_types */