12#ifndef __AUDACITY_COMPOSITE__
13#define __AUDACITY_COMPOSITE__
35 typename ComponentPointer,
36 typename... ComponentArgs
42 using Items = std::vector<value_type>;
44 explicit Base(ComponentArgs... args)
47 static_assert(std::has_virtual_destructor_v<Component>);
65 [[nodiscard]]
bool empty()
const {
return items.empty(); }
79template<
typename Base,
typename Derived>
struct Traits {
80 static constexpr auto ItemBuilder = std::move<typename Base::value_type>;
85template<
bool Deprecate>
struct This;
86template<>
struct This<false> {};
87template<>
struct [[deprecated(
98template<
typename Base,
typename Derived,
typename... BaseArgs>
106 -> std::enable_if_t<Traits<Base, Derived>
107 ::template enables_item_type_v<Arg>,
118 ::template enables_item_type_v<typename Base::value_type>;
122 if constexpr(!enable) {
132 template<
typename...
Items>
140 template<
typename InputIterator,
141 typename Arg =
decltype(*std::declval<InputIterator>()),
143 typename sfinae = std::enable_if_t<std::is_invocable_v<ItemBuilder, Arg>>>
147 [](Arg &&arg) -> decltype(auto) {
return std::forward<Arg>(arg); }
152 template<
typename InputIterator,
typename Transformer,
153 typename Arg =
decltype(*std::declval<InputIterator>()),
155 typename sfinae = std::enable_if_t<std::is_invocable_v<
156 ItemBuilder, std::invoke_result_t<Transformer, Arg>>>>
158 InputIterator
begin, InputIterator
end, Transformer transformer
161 [
this, &transformer](Arg &&arg){ push_back(transformer(arg)); });
165 using BaseType::push_back;
172 typename... RequiredBaseArgs
178 template<
typename... OtherBaseArgs>
180 OtherBaseArgs &&...otherArgs
184 , Base2{
std::move(arg2) }
191 typename... RequiredBaseArgs
199 template<
typename... OtherBaseArgs>
200 Extension(RequiredBaseArgs... args, OtherBaseArgs &&...otherArgs)
Base(ComponentArgs... args)
ComponentPointer value_type
Base & operator=(const Base &)=delete
void push_back(value_type ptr)
std::vector< value_type > Items
Base(const Base &)=delete
auto size() const noexcept
const char * end(const char *str) noexcept
const char * begin(const char *str) noexcept
Builder(BaseArgs... args, InputIterator begin, InputIterator end, Transformer transformer)
Iterator range constructor, with explicit transformer.
Builder(BaseArgs... args, Items &&... items)
Variadic constructor.
Builder(BaseArgs... args, InputIterator begin, InputIterator end)
Iterator range constructor, with default transformer.
void push_back(typename Base::value_type arg)
auto push_back(Arg &&arg) -> std::enable_if_t< Traits< Base, Derived > ::template enables_item_type_v< Arg >, void >
Extension(RequiredBaseArgs... args, OtherBaseArgs &&...otherArgs)
Extend Base with extra fields, in a second, protected base class.
Extension(RequiredBaseArgs... args, Base2 arg2, OtherBaseArgs &&...otherArgs)
static constexpr auto ItemBuilder
static constexpr auto enables_item_type_v