8template<
typename base_t>
11template<
typename... Ts>
33template<
typename base_t,
typename... tail_t>
42 static_assert(!
decltype(others)::template has<base_t>(),
"Each type can only be listed once.");
44 template<
typename count_t>
45 static consteval size_t count() {
46 return decltype(first)::template count<count_t>() +
47 decltype(others)::template count<count_t>();
50 static consteval size_t count() {
51 return 1 +
decltype(others)
::count();
59 template<
typename has_t>
60 static consteval bool has() {
61 return decltype(first)::template has<has_t>() ||
62 decltype(others)::template has<has_t>();
71 template<
typename func_t>
77 template<
typename func_t>
86 template<
typename return_t,
typename func_t>
87 decltype(
auto)
aggregate(func_t
const& accumulator, return_t seed) {
88 return others.aggregate(accumulator, first.aggregate(accumulator, seed));
91 template<
typename return_t,
typename func_t>
92 decltype(
auto)
aggregate(func_t
const& accumulator, return_t seed)
const {
93 return others.aggregate(accumulator, first.aggregate(accumulator, seed));
105 template<
typename get_t>
106 constexpr decltype(
auto)
get() {
107 static_assert(has<get_t>(),
"Type not found in type_list");
108 if constexpr (
decltype(first)::template has<get_t>()) {
109 return first.template get<get_t>();
111 return others.template get<get_t>();
115 template<
typename get_t>
116 constexpr decltype(
auto)
get()
const {
117 static_assert(has<get_t>(),
"Type not found in type_list");
118 if constexpr (
decltype(first)::template has<get_t>()) {
119 return first.template get<get_t>();
121 return others.template get<get_t>();
129template<
typename base_t>
135 template<
typename count_t>
137 return std::is_same_v<base_t, count_t> ? 1 : 0;
144 template<
typename func_t>
149 template<
typename func_t>
154 template<
typename return_t,
typename func_t>
155 decltype(
auto)
aggregate(func_t
const& accumulator, return_t seed) {
156 return accumulator(me, seed);
159 template<
typename return_t,
typename func_t>
160 decltype(
auto)
aggregate(func_t
const& accumulator, return_t seed)
const {
161 return accumulator(me, seed);
164 template<
typename has_t>
165 static consteval bool has() {
166 return std::is_same_v<has_t, base_t>;
169 template<typename get_t, typename = std::enable_if_t<has<get_t>()>>
174 template<typename get_t, typename = std::enable_if_t<has<get_t>()>>
175 constexpr auto const&
get()
const {
211template<
typename base_t>
222template<
typename base_t>
226 std::unique_ptr<base_t> me = std::make_unique<base_t>();
231 template<
typename count_t>
233 return std::is_same_v<base_t, count_t> ? 1 : 0;
240 template<
typename func_t>
245 template<
typename func_t>
250 template<
typename return_t,
typename func_t>
251 decltype(
auto)
aggregate(func_t
const& accumulator, return_t seed) {
252 return accumulator(*me, seed);
255 template<
typename return_t,
typename func_t>
256 decltype(
auto)
aggregate(func_t
const& accumulator, return_t seed)
const {
257 return accumulator(*me, seed);
260 template<
typename has_t>
261 static consteval bool has() {
262 return std::is_same_v<has_t, base_t>;
265 template<typename get_t, typename = std::enable_if_t<has<get_t>()>>
270 template<typename get_t, typename = std::enable_if_t<has<get_t>()>>
271 constexpr auto const&
get()
const {
constexpr interface_t * operator->()
static consteval bool has()
static consteval size_t count()
constexpr auto const & get() const
static consteval size_t count()
void constexpr apply_all(func_t const &f) const
typename base_t::interface_t interface_t
decltype(auto) aggregate(func_t const &accumulator, return_t seed) const
auto const & unmock() const
void constexpr apply_all(func_t const &f)
constexpr interface_t & operator*()
decltype(auto) aggregate(func_t const &accumulator, return_t seed)
constexpr interface_t const * operator->() const
void constexpr set(interface_t *ptr)
constexpr interface_t const & operator*() const
type_list< base_t > first
virtual ~type_list()=default
static consteval size_t count()
constexpr decltype(auto) get()
static consteval size_t count()
static consteval bool has()
decltype(auto) aggregate(func_t const &accumulator, return_t seed) const
void constexpr apply_all(func_t const &f) const
decltype(auto) aggregate(func_t const &accumulator, return_t seed)
void constexpr apply_all(func_t const &f)
constexpr decltype(auto) get() const
type_list< tail_t... > others
constexpr auto const & get() const
constexpr auto const & unmock() const
constexpr auto & unmock()
constexpr auto const & operator*() const
constexpr auto operator->() const
static consteval size_t count()
decltype(auto) aggregate(func_t const &accumulator, return_t seed) const
static consteval size_t count()
decltype(auto) aggregate(func_t const &accumulator, return_t seed)
static consteval bool has()
void constexpr apply_all(func_t const &f) const
constexpr auto operator->()
constexpr auto & operator*()
void constexpr apply_all(func_t const &f)