Changeset 10987
- Timestamp:
- Dec 28, 2015, 10:17:50 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/libraries/core/command/Functor.h
r10986 r10987 421 421 { typedef T Type; }; 422 422 423 // Helper structs to deduce the first N types of a parameter pack423 // Helper structs to deduce the first N types of a parameter pack 424 424 template<class... Types> struct type_list {}; 425 425 … … 564 564 565 565 private: 566 /// Helper function that deduces a parameter pack of types and returns the corresponding identifier566 /// Helper function that deduces a parameter pack of types and returns the corresponding identifier 567 567 template<class... Types> 568 568 const std::type_info& getTypelistIdentifier(detail::type_list<Types...>) const … … 575 575 namespace detail 576 576 { 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 }; 580 584 } 581 585 … … 589 593 590 594 /** 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 object595 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 592 596 } 593 597
Note: See TracChangeset
for help on using the changeset viewer.