libdl  0.0.1
Simple yet powerful deep learning
Loading...
Searching...
No Matches
composed.hpp
1#pragma once
2
3#include <functional>
4
5namespace dl::utils {
16 template <class F, class... Fs>
17 auto composed(F&& arg, Fs&&... args) {
18 return [fun = std::forward<F>(arg), ... functions = std::forward<Fs>(args)]<class X>(X&& x) mutable {
19 if constexpr (sizeof...(Fs)) {
20 return composed(std::forward<Fs>(functions)...)(std::invoke(std::forward<F>(fun), std::forward<X>(x)));
21 } else {
22 return std::invoke(std::forward<F>(fun), std::forward<X>(x));
23 }
24 };
25 }
26} // namespace dl::utils