48 lines
1.2 KiB
C++
48 lines
1.2 KiB
C++
/*
|
||
* 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_ */
|