Apply a custom transformation function within the chain.
225 {
227 error<std::runtime_error>(
229 std::source_location::current(),
230 "Cannot continue chain after failed operation in apply");
231 }
232
233 using ResultType = std::invoke_result_t<Func, const DataType&>;
234
235 try {
236 auto result = std::forward<Func>(func)(
m_data.
data);
237 auto next = FluentExecutor<Executor, ResultType>(
238 m_executor, Datum<ResultType>(std::move(result)));
240 next.m_operation_history.push_back("custom_function");
241 return next;
242 } catch (const std::exception& e) {
244 record_error(std::string(
"Custom function failed: ") + e.what());
247 std::source_location::current(),
248 "Exception in custom function: " + std::string(e.what()));
249 }
250 }
void record_error(const std::string &err)
std::shared_ptr< Executor > m_executor
std::vector< std::string > m_operation_history
@ ComputeMatrix
Compute operations (Yantra - algorithms, matrices, DSP)
void error_rethrow(Component component, Context context, std::source_location location=std::source_location::current(), std::string_view additional_context="")
Catch and log an exception, then rethrow it.
@ Yantra
DSP algorithms, computational units, matrix operations, Grammar.
T data
The actual computation data.