[Orxonox-commit 6330] r10987 - code/branches/cpp11_v2/src/libraries/core/command
landauf at orxonox.net
landauf at orxonox.net
Mon Dec 28 22:17:50 CET 2015
Author: landauf
Date: 2015-12-28 22:17:50 +0100 (Mon, 28 Dec 2015)
New Revision: 10987
Modified:
code/branches/cpp11_v2/src/libraries/core/command/Functor.h
Log:
now it also works with MSVC to wrap an std::function in a Functor
Modified: code/branches/cpp11_v2/src/libraries/core/command/Functor.h
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/command/Functor.h 2015-12-28 17:57:26 UTC (rev 10986)
+++ code/branches/cpp11_v2/src/libraries/core/command/Functor.h 2015-12-28 21:17:50 UTC (rev 10987)
@@ -420,7 +420,7 @@
struct GetNthParamType<0, T, Other...>
{ typedef T Type; };
- //Helper structs to deduce the first N types of a parameter pack
+ // Helper structs to deduce the first N types of a parameter pack
template<class... Types> struct type_list {};
template <class T1, class... AllTypes>
@@ -563,7 +563,7 @@
}
private:
- ///Helper function that deduces a parameter pack of types and returns the corresponding identifier
+ /// Helper function that deduces a parameter pack of types and returns the corresponding identifier
template<class... Types>
const std::type_info& getTypelistIdentifier(detail::type_list<Types...>) const
{
@@ -574,9 +574,13 @@
namespace detail
{
- //Helper functions to deduce types and constness of operator() and return the correct FunctorCallable
- template <class F, class R, class... Params> inline FunctorStaticPtr callableHelper(const F& functionObject, R(F::*)(Params...)) { return std::make_shared<FunctorTemplate<F, R, void, false, Params...>>(functionObject); }
- template <class F, class R, class... Params> inline FunctorStaticPtr callableHelper(const F& functionObject, R(F::*)(Params...) const) { return std::make_shared<FunctorTemplate<F, R, void, false, Params...>>(functionObject); } // note: both const and non-const function-objects are treated as static functors with isconst=false.
+ // Helper functions to deduce types and constness of operator() and return the correct FunctorTemplate
+ template <class F>
+ struct CallableHelper
+ {
+ template <class R, class... Params> static inline FunctorStaticPtr create(const F& functionObject, R(F::*)(Params...)) { return std::make_shared<FunctorTemplate<F, R, void, false, Params...>>(functionObject); }
+ template <class R, class... Params> static inline FunctorStaticPtr create(const F& functionObject, R(F::*)(Params...) const) { return std::make_shared<FunctorTemplate<F, R, void, false, Params...>>(functionObject); } // note: both const and non-const function-objects are treated as static functors with isconst=false.
+ };
}
template <class R, class O, class OO, class... Params> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(Params...), OO* object) { return std::make_shared<FunctorTemplate<void, R, O, false, Params...>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
@@ -588,7 +592,7 @@
template <class R, class... Params> inline FunctorStaticPtr createFunctor(R (*functionPointer)(Params...)) { return std::make_shared<FunctorTemplate<void, R, void, false, Params...>>(functionPointer); } ///< Creates a new FunctorStatic with the given function-pointer
/** Take care that this functor does not outlive objects that have been captured by reference in a lambda. */
- template <class F> inline FunctorStaticPtr createFunctor(const F& functionObject) { return detail::callableHelper(functionObject, &F::operator()); } ///< Creates a new Functor with a callable object
+ template <class F> inline FunctorStaticPtr createFunctor(const F& functionObject) { return detail::CallableHelper<F>::create(functionObject, &F::operator()); } ///< Creates a new Functor with a callable object
}
#endif /* _Functor_H__ */
More information about the Orxonox-commit
mailing list