MotorControlModuleSDFM_TMS3.../Projects/EFC_Communication/UMLibrary/systemic/FunctorLazyFast.hpp
2024-06-07 11:12:56 +03:00

48 lines
1.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* FunctorLazyFast.hpp
*
* Created on: 17 июн. 2020 г.
* Author: LeonidTitov
*/
#ifndef UMLIBRARY_SYSTEMIC_FUNCTORLAZYFAST_HPP_
#define UMLIBRARY_SYSTEMIC_FUNCTORLAZYFAST_HPP_
#include "IFunctor.hh"
namespace systemic { namespace detail {
template<typename Object, typename Return, typename ... Args>
class FunctorLazyFast : public IFunctor<Return, Args...> {
private:
Object & object;
Return (Object::* const pf)(Args...);
public:
typedef Return (Object::* Function)(Args...);
FunctorLazyFast( Object & obj, Function pf );
Return operator()( Args ... args );
FunctorLazyFast(const FunctorLazyFast &) = delete;
FunctorLazyFast & operator=(const FunctorLazyFast &) = delete;
};
}
}
template<typename Object, typename Return, typename ... Args>
inline systemic::detail::FunctorLazyFast<Object, Return, Args...>::FunctorLazyFast(
Object & obj, Return (Object::* const pf)(Args...) ) : object(obj), pf(pf) {}
template<typename Object, typename Return, typename ... Args>
inline Return systemic::detail::FunctorLazyFast<Object, Return, Args...>::operator ()(
Args ... args) {
return (object.*pf)( args... );
}
#endif /* UMLIBRARY_SYSTEMIC_FUNCTORLAZYFAST_HPP_ */