Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10987


Ignore:
Timestamp:
Dec 28, 2015, 10:17:50 PM (8 years ago)
Author:
landauf
Message:

now it also works with MSVC to wrap an std::function in a Functor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/libraries/core/command/Functor.h

    r10986 r10987  
    421421        { typedef T Type; };
    422422
    423         //Helper structs to deduce the first N types of a parameter pack
     423        // Helper structs to deduce the first N types of a parameter pack
    424424        template<class... Types> struct type_list {};
    425425
     
    564564
    565565    private:
    566             ///Helper function that deduces a parameter pack of types and returns the corresponding identifier
     566            /// Helper function that deduces a parameter pack of types and returns the corresponding identifier
    567567            template<class... Types>
    568568            const std::type_info& getTypelistIdentifier(detail::type_list<Types...>) const
     
    575575    namespace detail
    576576    {
    577         //Helper functions to deduce types and constness of operator() and return the correct FunctorCallable
    578         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); }
    579         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.
     577        // Helper functions to deduce types and constness of operator() and return the correct FunctorTemplate
     578        template <class F>
     579        struct CallableHelper
     580        {
     581            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); }
     582            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.
     583        };
    580584    }
    581585
     
    589593
    590594    /** Take care that this functor does not outlive objects that have been captured by reference in a lambda. */
    591     template <class F> inline FunctorStaticPtr createFunctor(const F& functionObject) { return detail::callableHelper(functionObject, &F::operator()); } ///< Creates a new Functor with a callable object
     595    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
    592596}
    593597
Note: See TracChangeset for help on using the changeset viewer.