.. _program_listing_file_include_ripple_functional_invocable.hpp: Program Listing for File invocable.hpp ====================================== |exhale_lsh| :ref:`Return to documentation for file ` (``include/ripple/functional/invocable.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #ifndef RIPPLE_FUNCTIONAL_INVOCABLE_HPP #define RIPPLE_FUNCTIONAL_INVOCABLE_HPP #include "functional_traits.hpp" #include #include #include namespace ripple { template class Invocable { public: /*==--- [construction] ---------------------------------------------------==*/ template ripple_all Invocable(F&& functor) noexcept : functor_{ripple_forward(functor)} {} ripple_all Invocable(const Functor& functor) noexcept : functor_{functor} {} ripple_all Invocable(const Invocable& other) noexcept : functor_{other.functor_} {} ripple_all Invocable(Invocable&& other) noexcept : functor_{ripple_move(other._functor)} {} ripple_all auto operator=(const Invocable& other) noexcept -> Invocable& { functor_ = other.functor_; return *this; } ripple_all auto operator=(Invocable&& other) noexcept -> Invocable& { if (&other != this) { functor_ = ripple_move(other.functor_); } return *this; } /*==--- [interface] ------------------------------------------------------==*/ template ripple_all auto operator()(Args&&... args) const noexcept -> void { functor_(ripple_forward(args)...); } template ripple_all auto operator()(Args&&... args) noexcept -> void { functor_(ripple_forward(args)...); } private: Functor functor_; }; /*==--- [functions] -------------------------------------------------------==*/ template ripple_all decltype(auto) make_invocable(Functor&& functor) noexcept { return Invocable>{ripple_forward(functor)}; } } // namespace ripple #endif // RIPPLE_FUNCTIONAL_INVOCABLE_HPP