15class ErasedOperation {
17 template <SomeOperation OpType>
18 requires(not std::is_same_v<std::decay_t<OpType>, ErasedOperation>)
19 ErasedOperation(OpType&& operation)
20 : pimpl_{std::make_unique<Model<OpType>>(std::forward<OpType>(operation))}
24 ~ErasedOperation() =
default;
26 ErasedOperation(ErasedOperation
const&) =
delete;
27 ErasedOperation(ErasedOperation&&) =
default;
30 operator=(ErasedOperation
const&) =
delete;
32 operator=(ErasedOperation&&) =
default;
40 std::expected<std::any, ExecutionError>
63 virtual ~Concept() =
default;
76 struct Model : Concept {
79 template <
typename OType>
80 requires std::is_same_v<OType, OpType>
81 Model(OType&& operation) : operation{std::forward<OType>(operation)}
86 wait() noexcept
override
88 if constexpr (not SomeAwaitable<OpType>) {
89 ASSERT(
false,
"Called wait() on an operation that does not support it");
96 std::expected<std::any, ExecutionError>
99 if constexpr (not SomeOperationWithData<OpType>) {
100 ASSERT(
false,
"Called get() on an operation that does not support it");
105 return operation.get();
113 not SomeCancellableOperation<OpType> and not SomeStoppableOperation<OpType> and
114 not SomeAbortable<OpType>
118 "Called abort() on an operation that can't be aborted, cancelled nor stopped"
121 if constexpr (SomeAbortable<OpType>) {
124 if constexpr (SomeCancellableOperation<OpType>)
126 if constexpr (SomeStoppableOperation<OpType>)
127 operation.requestStop();
135 if constexpr (not SomeForceInvocableOperation<OpType>) {
136 ASSERT(
false,
"Called invoke() on an operation that can't be force-invoked");
144 std::unique_ptr<Concept> pimpl_;