MotorControlModuleSDFM_TMS3.../Projects/EFC_Application/UMLibrary/systemic/FunctorLazyFast.hpp

48 lines
1.2 KiB
C++
Raw Normal View History

/*
* FunctorLazyFast.hpp
*
* Created on: 17 <EFBFBD><EFBFBD><EFBFBD>. 2020 <EFBFBD>.
* 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_ */