6 template<
typename base_t>
28 template<
typename base_t,
typename... tail_t>
33 static_assert(!decltype(
others)::
template has<base_t>(),
34 "Each type can only be listed once.");
42 template<
typename func_t>
51 template<
typename return_t,
typename func_t>
52 auto aggregate(func_t
const& accumulator, return_t seed) {
65 template<
typename get_t>
66 constexpr
auto get() -> std::enable_if_t<decltype(first)::template has<get_t>(),
67 decltype(
first.template get<get_t>())> {
68 return first.template get<get_t>();
71 template<
typename get_t>
72 constexpr
auto get() -> std::enable_if_t<!decltype(first)::template has<get_t>(),
73 decltype(
others.template get<get_t>())> {
74 return others.template get<get_t>();
82 template<
typename has_t>
83 static constexpr
bool has() {
84 return decltype(
first)::
template has<has_t>() ||
85 decltype(
others)::
template has<has_t>();
92 template<
typename base_t>
98 template<
typename func_t>
103 template<
typename return_t,
typename func_t>
104 auto aggregate(func_t
const& accumulator, return_t seed) {
105 return accumulator(me, seed);
108 template<
typename has_t>
109 static constexpr
bool has() {
110 return std::is_same_v<has_t, base_t>;
113 template<typename get_t, typename = std::enable_if_t<has<get_t>()>>
138 template<
typename base_t>
149 template<
typename base_t>
153 std::unique_ptr<base_t> me = std::make_unique<base_t>();
154 typename base_t::interface_t * cur = me.get();
157 template<
typename func_t>
162 template<
typename return_t,
typename func_t>
163 auto aggregate(func_t
const& accumulator, return_t seed) {
164 return accumulator(*me, seed);
167 template<
typename has_t>
168 static constexpr
bool has() {
169 return std::is_same_v<has_t, base_t>;
172 template<typename get_t, typename = std::enable_if_t<has<get_t>()>>
181 void set(
typename base_t::interface_t * ptr) {
void set(typename base_t::interface_t *ptr)
constexpr auto & operator*()
void apply_all(func_t const &f)
constexpr auto * operator->()
static constexpr bool has()
auto aggregate(func_t const &accumulator, return_t seed)
constexpr base_t * operator->()
auto aggregate(func_t const &accumulator, return_t seed)
constexpr base_t & operator*()
constexpr auto & unmock()
static constexpr bool has()
void apply_all(func_t const &f)
static constexpr bool has()
auto aggregate(func_t const &accumulator, return_t seed)
constexpr auto get() -> std::enable_if_t< decltype(first)::template has< get_t >(), decltype(first.template get< get_t >())>
void apply_all(func_t const &f)
type_list< base_t > first
constexpr auto get() -> std::enable_if_t<!decltype(first)::template has< get_t >(), decltype(others.template get< get_t >())>
type_list< tail_t... > others