Changeset 10876 for code/branches
- Timestamp:
- Nov 27, 2015, 4:19:06 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/libraries/core/command/Functor.h
r10845 r10876 116 116 #include "core/CorePrereqs.h" 117 117 118 #include <typeinfo> 118 #include <array> 119 #include <typeindex> 120 #include <tuple> 119 121 120 122 #include "util/Output.h" … … 219 221 220 222 /// Returns the full identifier of the function-pointer which is defined as typeid(@a F), where @a F is the type of the stored function-pointer. Used to compare functors. 221 virtual const std::type_in fo&getFullIdentifier() const = 0;223 virtual const std::type_index getFullIdentifier() const = 0; 222 224 /// Returns an identifier of the header of the function (doesn't include the function's class). Used to compare functors. 223 virtual const std::type_in fo&getHeaderIdentifier() const = 0;225 virtual const std::type_index getHeaderIdentifier() const = 0; 224 226 /// Returns an identifier of the header of the function (doesn't include the function's class), but regards only the first @a params parameters. Used to compare functions if an Executor provides default-values for the other parameters. 225 virtual const std::type_in fo&getHeaderIdentifier(unsigned int params) const = 0;227 virtual const std::type_index getHeaderIdentifier(unsigned int params) const = 0; 226 228 }; 227 229 … … 379 381 380 382 // see Functor::getFullIdentifier() 381 const std::type_in fo&getFullIdentifier() const383 const std::type_index getFullIdentifier() const 382 384 { return typeid(F); } 383 385 … … 389 391 { 390 392 // Helper class to get the type of the function pointer with the given class, parameters, return-value, and constness 391 template <class R, class O, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctionPointer { typedef R (O::*Type)(P1, P2, P3, P4, P5); }; 392 template <class R, class O, class P1, class P2, class P3, class P4, class P5> struct FunctionPointer<R, O, false, P1, P2, P3, P4, P5> { typedef R (O::*Type)(P1, P2, P3, P4, P5); }; 393 template <class R, class O, class P1, class P2, class P3, class P4> struct FunctionPointer<R, O, false, P1, P2, P3, P4, void> { typedef R (O::*Type)(P1, P2, P3, P4); }; 394 template <class R, class O, class P1, class P2, class P3> struct FunctionPointer<R, O, false, P1, P2, P3, void, void> { typedef R (O::*Type)(P1, P2, P3); }; 395 template <class R, class O, class P1, class P2> struct FunctionPointer<R, O, false, P1, P2, void, void, void> { typedef R (O::*Type)(P1, P2); }; 396 template <class R, class O, class P1> struct FunctionPointer<R, O, false, P1, void, void, void, void> { typedef R (O::*Type)(P1); }; 397 template <class R, class O> struct FunctionPointer<R, O, false, void, void, void, void, void> { typedef R (O::*Type)(); }; 398 template <class R, class O, class P1, class P2, class P3, class P4, class P5> struct FunctionPointer<R, O, true, P1, P2, P3, P4, P5> { typedef R (O::*Type)(P1, P2, P3, P4, P5) const; }; 399 template <class R, class O, class P1, class P2, class P3, class P4> struct FunctionPointer<R, O, true, P1, P2, P3, P4, void> { typedef R (O::*Type)(P1, P2, P3, P4) const; }; 400 template <class R, class O, class P1, class P2, class P3> struct FunctionPointer<R, O, true, P1, P2, P3, void, void> { typedef R (O::*Type)(P1, P2, P3) const; }; 401 template <class R, class O, class P1, class P2> struct FunctionPointer<R, O, true, P1, P2, void, void, void> { typedef R (O::*Type)(P1, P2) const; }; 402 template <class R, class O, class P1> struct FunctionPointer<R, O, true, P1, void, void, void, void> { typedef R (O::*Type)(P1) const; }; 403 template <class R, class O> struct FunctionPointer<R, O, true, void, void, void, void, void> { typedef R (O::*Type)() const; }; 404 template <class R, class P1, class P2, class P3, class P4, class P5> struct FunctionPointer<R, void, false, P1, P2, P3, P4, P5> { typedef R (*Type)(P1, P2, P3, P4, P5); }; 405 template <class R, class P1, class P2, class P3, class P4> struct FunctionPointer<R, void, false, P1, P2, P3, P4, void> { typedef R (*Type)(P1, P2, P3, P4); }; 406 template <class R, class P1, class P2, class P3> struct FunctionPointer<R, void, false, P1, P2, P3, void, void> { typedef R (*Type)(P1, P2, P3); }; 407 template <class R, class P1, class P2> struct FunctionPointer<R, void, false, P1, P2, void, void, void> { typedef R (*Type)(P1, P2); }; 408 template <class R, class P1> struct FunctionPointer<R, void, false, P1, void, void, void, void> { typedef R (*Type)(P1); }; 409 template <class R> struct FunctionPointer<R, void, false, void, void, void, void, void> { typedef R (*Type)(); }; 393 template <class R, class O, bool isconst, class... Params> struct FunctionPointer { typedef R (O::*Type)(Params...); }; 394 template <class R, class O, class... Params> struct FunctionPointer<R, O, true, Params...> { typedef R (O::*Type)(Params...) const; }; 395 template <class R, class... Params> struct FunctionPointer<R, void, false, Params...> { typedef R (*Type)(Params...); }; 410 396 411 397 // Helper class, used to call a function-pointer with a given object and parameters and to return its return-value (if available) 412 template <class R, class O, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, P5>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (object->*functionPointer)(param1, param2, param3, param4, param5); } }; 413 template <class R, class O, bool isconst, class P1, class P2, class P3, class P4> struct FunctorCaller<R, O, isconst, P1, P2, P3, P4, void> { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType&) { return (object->*functionPointer)(param1, param2, param3, param4); } }; 414 template <class R, class O, bool isconst, class P1, class P2, class P3> struct FunctorCaller<R, O, isconst, P1, P2, P3, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType&, const MultiType&) { return (object->*functionPointer)(param1, param2, param3); } }; 415 template <class R, class O, bool isconst, class P1, class P2> struct FunctorCaller<R, O, isconst, P1, P2, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType&, const MultiType&, const MultiType&) { return (object->*functionPointer)(param1, param2); } }; 416 template <class R, class O, bool isconst, class P1> struct FunctorCaller<R, O, isconst, P1, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, void, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { return (object->*functionPointer)(param1); } }; 417 template <class R, class O, bool isconst> struct FunctorCaller<R, O, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, void, void, void, void, void>::Type functionPointer, O* object, const MultiType&, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { return (object->*functionPointer)(); } }; 418 template <class O, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller<void, O, isconst, P1, P2, P3, P4, P5> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, P4, P5>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (object->*functionPointer)(param1, param2, param3, param4, param5); return MultiType::Null; } }; 419 template <class O, bool isconst, class P1, class P2, class P3, class P4> struct FunctorCaller<void, O, isconst, P1, P2, P3, P4, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, P4, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType&) { (object->*functionPointer)(param1, param2, param3, param4); return MultiType::Null; } }; 420 template <class O, bool isconst, class P1, class P2, class P3> struct FunctorCaller<void, O, isconst, P1, P2, P3, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType&, const MultiType&) { (object->*functionPointer)(param1, param2, param3); return MultiType::Null; } }; 421 template <class O, bool isconst, class P1, class P2> struct FunctorCaller<void, O, isconst, P1, P2, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType&, const MultiType&, const MultiType&) { (object->*functionPointer)(param1, param2); return MultiType::Null; } }; 422 template <class O, bool isconst, class P1> struct FunctorCaller<void, O, isconst, P1, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, void, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (object->*functionPointer)(param1); return MultiType::Null; } }; 423 template <class O, bool isconst> struct FunctorCaller<void, O, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, void, void, void, void, void>::Type functionPointer, O* object, const MultiType&, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (object->*functionPointer)(); return MultiType::Null; } }; 424 template <class R, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller<R, void, isconst, P1, P2, P3, P4, P5> { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, P3, P4, P5>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (*functionPointer)(param1, param2, param3, param4, param5); } }; 425 template <class R, bool isconst, class P1, class P2, class P3, class P4> struct FunctorCaller<R, void, isconst, P1, P2, P3, P4, void> { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, P3, P4, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType&) { return (*functionPointer)(param1, param2, param3, param4); } }; 426 template <class R, bool isconst, class P1, class P2, class P3> struct FunctorCaller<R, void, isconst, P1, P2, P3, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, P3, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType&, const MultiType&) { return (*functionPointer)(param1, param2, param3); } }; 427 template <class R, bool isconst, class P1, class P2> struct FunctorCaller<R, void, isconst, P1, P2, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType&, const MultiType&, const MultiType&) { return (*functionPointer)(param1, param2); } }; 428 template <class R, bool isconst, class P1> struct FunctorCaller<R, void, isconst, P1, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, void, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { return (*functionPointer)(param1); } }; 429 template <class R, bool isconst> struct FunctorCaller<R, void, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, void, void, void, void, void>::Type functionPointer, void*, const MultiType&, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { return (*functionPointer)(); } }; 430 template <bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller<void, void, isconst, P1, P2, P3, P4, P5> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, P4, P5>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (*functionPointer)(param1, param2, param3, param4, param5); return MultiType::Null; } }; 431 template <bool isconst, class P1, class P2, class P3, class P4> struct FunctorCaller<void, void, isconst, P1, P2, P3, P4, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, P4, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType&) { (*functionPointer)(param1, param2, param3, param4); return MultiType::Null; } }; 432 template <bool isconst, class P1, class P2, class P3> struct FunctorCaller<void, void, isconst, P1, P2, P3, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType&, const MultiType&) { (*functionPointer)(param1, param2, param3); return MultiType::Null; } }; 433 template <bool isconst, class P1, class P2> struct FunctorCaller<void, void, isconst, P1, P2, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType&, const MultiType&, const MultiType&) { (*functionPointer)(param1, param2); return MultiType::Null; } }; 434 template <bool isconst, class P1> struct FunctorCaller<void, void, isconst, P1, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, void, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (*functionPointer)(param1); return MultiType::Null; } }; 435 template <bool isconst> struct FunctorCaller<void, void, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, void, void, void, void, void>::Type functionPointer, void*, const MultiType&, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (*functionPointer)(); return MultiType::Null; } }; 398 template <class R, class O, bool isconst, class... Params> struct FunctorCaller { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, Params...>::Type functionPointer, O* object, const Params&... parameters) { return (object->*functionPointer)(parameters...); } }; 399 template <class O, bool isconst, class... Params> struct FunctorCaller<void, O, isconst, Params...> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, Params...>::Type functionPointer, O* object, const Params&... parameters) { (object->*functionPointer)(parameters...); return MultiType::Null; } }; 400 template <class R, bool isconst, class... Params> struct FunctorCaller<R, void, isconst, Params...> { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, Params...>::Type functionPointer, void*, const Params&... parameters) { return (*functionPointer)(parameters...); } }; 401 template <bool isconst, class... Params> struct FunctorCaller<void, void, isconst, Params...> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, Params...>::Type functionPointer, void*, const Params&... parameters) { (*functionPointer)(parameters...); return MultiType::Null; } }; 436 402 437 403 // Helper class, used to identify the header of a function-pointer (independent of its class) 438 template <class R, class P1, class P2, class P3, class P4, class P5>404 template <class R, class... Params> 439 405 struct FunctorHeaderIdentifier 440 406 {}; … … 448 414 { enum { result = false }; }; 449 415 450 // Helper class to count the number of parameters 451 template <class P1, class P2, class P3, class P4, class P5> 452 struct FunctorParamCount 453 { enum { result = 5 }; }; 454 template <class P1, class P2, class P3, class P4> 455 struct FunctorParamCount<P1, P2, P3, P4, void> 456 { enum { result = 4 }; }; 457 template <class P1, class P2, class P3> 458 struct FunctorParamCount<P1, P2, P3, void, void> 459 { enum { result = 3 }; }; 460 template <class P1, class P2> 461 struct FunctorParamCount<P1, P2, void, void, void> 462 { enum { result = 2 }; }; 463 template <class P1> 464 struct FunctorParamCount<P1, void, void, void, void> 465 { enum { result = 1 }; }; 466 template <> 467 struct FunctorParamCount<void, void, void, void, void> 468 { enum { result = 0 }; }; 416 //Barebones implementation of (make_)index_sequence for C++11 417 template <std::size_t...> struct index_sequence {}; 418 419 template <std::size_t N, std::size_t... Is> 420 struct make_index_sequence : make_index_sequence<N - 1, N - 1, Is...> {}; 421 422 template <std::size_t... Is> 423 struct make_index_sequence<0u, Is...> : index_sequence<Is...> {}; 424 425 //Helper structs to deduce the first N types of a parameter pack 426 template<class... Types> struct type_list {}; 427 428 template <class T1, class... AllTypes> 429 struct make_type_list_helper 430 { 431 template <std::size_t N, class... Types> 432 struct make_type_list_impl : make_type_list_helper<AllTypes...>::template make_type_list_impl<N - 1, Types..., T1> {}; 433 434 template <class... Types> 435 struct make_type_list_impl<1u, Types...> : type_list<Types..., T1> {}; 436 }; 437 438 template <std::size_t N, class... Types> 439 struct make_type_list : make_type_list_helper<Types...>::template make_type_list_impl<N> {}; 440 441 template <class... Types> 442 struct make_type_list<0u, Types...> : type_list<> {}; 469 443 } 470 444 … … 489 463 All template arguments can be void. 490 464 */ 491 template <class R, class O, bool isconst, class P1, class P2, class P3, class P4, class P5> 492 class FunctorTemplate : public FunctorPointer<typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, P5>::Type, O> 493 { 465 template <class R, class O, bool isconst, class... Params> 466 class FunctorTemplate : public FunctorPointer<typename detail::FunctionPointer<R, O, isconst, Params...>::Type, O> 467 { 468 static_assert(sizeof...(Params) <= 5, "Only up to 5 parameters are supported"); 469 494 470 public: 495 471 /// Constructor: Initializes the base class. 496 FunctorTemplate(typename detail::FunctionPointer<R, O, isconst, P 1, P2, P3, P4, P5>::Type functionPointer, O* object = nullptr) : FunctorPointer<typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, P5>::Type, O>(functionPointer, object) {}472 FunctorTemplate(typename detail::FunctionPointer<R, O, isconst, Params...>::Type functionPointer, O* object = nullptr) : FunctorPointer<typename detail::FunctionPointer<R, O, isconst, Params...>::Type, O>(functionPointer, object) {} 497 473 498 474 // see FunctorMember::operator()() 499 MultiType operator()(O* object, const MultiType& param1 = MultiType::Null, const MultiType& param2 = MultiType::Null, const MultiType& param3 = MultiType::Null, const MultiType& param4 = MultiType::Null, const MultiType& param5 = MultiType::Null) 500 { 501 return detail::FunctorCaller<R, O, isconst, P1, P2, P3, P4, P5>::call(this->functionPointer_, object, param1, param2, param3, param4, param5); 475 virtual MultiType operator()(O* object, const MultiType& param1 = MultiType::Null, const MultiType& param2 = MultiType::Null, const MultiType& param3 = MultiType::Null, const MultiType& param4 = MultiType::Null, const MultiType& param5 = MultiType::Null) override 476 { 477 auto multis = std::make_tuple(param1, param2, param3, param4, param5); 478 return callHelper(object, multis, detail::make_index_sequence<sizeof...(Params)>{}); 502 479 } 503 480 504 481 // see Functor::clone() 505 FunctorPtr clone()482 virtual FunctorPtr clone() override 506 483 { 507 484 return std::make_shared<FunctorTemplate>(*this); … … 509 486 510 487 // see Functor::evaluateArgument() 511 void evaluateArgument(unsigned int index, MultiType& argument) const 512 { 513 switch (index) 488 virtual void evaluateArgument(unsigned int index, MultiType& argument) const override 489 { 490 static const std::array<std::function<bool(MultiType&)>, sizeof...(Params)> funcs = {&MultiType::convert<Params>...}; 491 if (index < funcs.size()) 514 492 { 515 case 0: argument.convert<P1>(); break; 516 case 1: argument.convert<P2>(); break; 517 case 2: argument.convert<P3>(); break; 518 case 3: argument.convert<P4>(); break; 519 case 4: argument.convert<P5>(); break; 493 funcs[index](argument); 520 494 } 521 495 } 522 496 523 497 // see Functor::getParamCount() 524 unsigned int getParamCount() const525 { 526 return detail::FunctorParamCount<P1, P2, P3, P4, P5>::result;498 virtual unsigned int getParamCount() const override 499 { 500 return sizeof...(Params); 527 501 } 528 502 529 503 // see Functor::hasReturnvalue() 530 bool hasReturnvalue() const504 virtual bool hasReturnvalue() const override 531 505 { 532 506 return detail::FunctorHasReturnvalue<R>::result; … … 534 508 535 509 // see Functor::getTypenameParam() 536 std::string getTypenameParam(unsigned int index) const 537 { 538 switch (index) 510 virtual std::string getTypenameParam(unsigned int index) const override 511 { 512 static const std::array<std::string, sizeof...(Params)> names = { typeToString<Params>()... }; 513 if (index >= names.size()) 539 514 { 540 case 0: return typeToString<P1>(); 541 case 1: return typeToString<P2>(); 542 case 2: return typeToString<P3>(); 543 case 3: return typeToString<P4>(); 544 case 4: return typeToString<P5>(); 545 default: return ""; 515 return ""; 546 516 } 517 return names[index]; 547 518 } 548 519 549 520 // see Functor::getTypenameReturnvalue() 550 std::string getTypenameReturnvalue() const521 virtual std::string getTypenameReturnvalue() const override 551 522 { 552 523 return typeToString<R>(); … … 554 525 555 526 // see Functor::getHeaderIdentifier() 556 const std::type_info& getHeaderIdentifier() const557 { 558 return typeid(detail::FunctorHeaderIdentifier<R, P 1, P2, P3, P4, P5>);527 virtual const std::type_index getHeaderIdentifier() const override 528 { 529 return typeid(detail::FunctorHeaderIdentifier<R, Params...>); 559 530 } 560 531 561 532 // see Functor::getHeaderIdentifier(unsigned int) 562 const std::type_info& getHeaderIdentifier(unsigned int params) const 563 { 564 switch (params) 533 virtual const std::type_index getHeaderIdentifier(unsigned int params) const override 534 { 535 //+1 because e.g. for two parameters, we want typeids for zero, one, or two parameters 536 return getHeaderIdentifierHelper(params, detail::make_index_sequence<sizeof...(Params) + 1>{}); 537 } 538 539 private: 540 541 /// Helper function that extracts index numbers of parameters from a tuple. Needed to call the function pointer with the correct amount of arguments. 542 template<typename Tup, std::size_t... index> 543 MultiType callHelper(O* object, Tup&& tup, detail::index_sequence<index...>) 544 { 545 return detail::FunctorCaller<R, O, isconst, Params...>::call(this->functionPointer_, object, std::get<index>(std::forward<Tup>(tup))...); 546 } 547 548 /// Helper function to extract all identifiers of the function pointer using a deduced index sequence 549 template<std::size_t... index> 550 const std::type_index& getHeaderIdentifierHelper(unsigned int params, detail::index_sequence<index...>) const 551 { 552 static const std::array<const std::type_index, sizeof...(index)> typeinfos = { getTypelistIdentifier(detail::make_type_list<index, Params...>{})... }; 553 if (params >= typeinfos.size()) 565 554 { 566 case 0: return typeid(detail::FunctorHeaderIdentifier<R, void, void, void, void, void>); 567 case 1: return typeid(detail::FunctorHeaderIdentifier<R, P1, void, void, void, void>); 568 case 2: return typeid(detail::FunctorHeaderIdentifier<R, P1, P2, void, void, void>); 569 case 3: return typeid(detail::FunctorHeaderIdentifier<R, P1, P2, P3, void, void>); 570 case 4: return typeid(detail::FunctorHeaderIdentifier<R, P1, P2, P3, P4, void>); 571 default: return typeid(detail::FunctorHeaderIdentifier<R, P1, P2, P3, P4, P5>); 555 return typeinfos.back(); 572 556 } 557 return typeinfos[params]; 558 } 559 560 ///Helper function that deduces a parameter pack of types and returns the corresponding identifier 561 template<class... Types> 562 const std::type_index getTypelistIdentifier(detail::type_list<Types...>) const 563 { 564 return typeid(detail::FunctorHeaderIdentifier<R, Types...>); 573 565 } 574 566 }; 575 567 576 template <class R, class O, class OO, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5), OO* object) { return std::make_shared<FunctorTemplate<R, O, false, P1, P2, P3, P4, P5>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 577 template <class R, class O, class OO, class P1, class P2, class P3, class P4> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4), OO* object) { return std::make_shared<FunctorTemplate<R, O, false, P1, P2, P3, P4, void>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 578 template <class R, class O, class OO, class P1, class P2, class P3> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3), OO* object) { return std::make_shared<FunctorTemplate<R, O, false, P1, P2, P3, void, void>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 579 template <class R, class O, class OO, class P1, class P2> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2), OO* object) { return std::make_shared<FunctorTemplate<R, O, false, P1, P2, void, void, void>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 580 template <class R, class O, class OO, class P1> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1), OO* object) { return std::make_shared<FunctorTemplate<R, O, false, P1, void, void, void, void>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 581 template <class R, class O, class OO> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(), OO* object) { return std::make_shared<FunctorTemplate<R, O, false, void, void, void, void, void>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 582 template <class R, class O, class OO, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5) const, OO* object) { return std::make_shared<FunctorTemplate<R, O, true, P1, P2, P3, P4, P5>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 583 template <class R, class O, class OO, class P1, class P2, class P3, class P4> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4) const, OO* object) { return std::make_shared<FunctorTemplate<R, O, true, P1, P2, P3, P4, void>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 584 template <class R, class O, class OO, class P1, class P2, class P3> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3) const, OO* object) { return std::make_shared<FunctorTemplate<R, O, true, P1, P2, P3, void, void>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 585 template <class R, class O, class OO, class P1, class P2> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2) const, OO* object) { return std::make_shared<FunctorTemplate<R, O, true, P1, P2, void, void, void>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 586 template <class R, class O, class OO, class P1> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1) const, OO* object) { return std::make_shared<FunctorTemplate<R, O, true, P1, void, void, void, void>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 587 template <class R, class O, class OO> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)() const, OO* object) { return std::make_shared<FunctorTemplate<R, O, true, void, void, void, void, void>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 588 589 template <class R, class O, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5)) { return std::make_shared<FunctorTemplate<R, O, false, P1, P2, P3, P4, P5>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 590 template <class R, class O, class P1, class P2, class P3, class P4> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4)) { return std::make_shared<FunctorTemplate<R, O, false, P1, P2, P3, P4, void>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 591 template <class R, class O, class P1, class P2, class P3> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3)) { return std::make_shared<FunctorTemplate<R, O, false, P1, P2, P3, void, void>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 592 template <class R, class O, class P1, class P2> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2)) { return std::make_shared<FunctorTemplate<R, O, false, P1, P2, void, void, void>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 593 template <class R, class O, class P1> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1)) { return std::make_shared<FunctorTemplate<R, O, false, P1, void, void, void, void>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 594 template <class R, class O> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)()) { return std::make_shared<FunctorTemplate<R, O, false, void, void, void, void, void>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 595 template <class R, class O, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5) const) { return std::make_shared<FunctorTemplate<R, O, true, P1, P2, P3, P4, P5>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 596 template <class R, class O, class P1, class P2, class P3, class P4> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4) const) { return std::make_shared<FunctorTemplate<R, O, true, P1, P2, P3, P4, void>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 597 template <class R, class O, class P1, class P2, class P3> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3) const) { return std::make_shared<FunctorTemplate<R, O, true, P1, P2, P3, void, void>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 598 template <class R, class O, class P1, class P2> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2) const) { return std::make_shared<FunctorTemplate<R, O, true, P1, P2, void, void, void>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 599 template <class R, class O, class P1> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1) const) { return std::make_shared<FunctorTemplate<R, O, true, P1, void, void, void, void>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 600 template <class R, class O> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)() const) { return std::make_shared<FunctorTemplate<R, O, true, void, void, void, void, void>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 601 602 template <class R, class P1, class P2, class P3, class P4, class P5> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2, P3, P4, P5)) { return std::make_shared<FunctorTemplate<R, void, false, P1, P2, P3, P4, P5>>(functionPointer); } ///< Creates a new Functor with the given function-pointer 603 template <class R, class P1, class P2, class P3, class P4> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2, P3, P4)) { return std::make_shared<FunctorTemplate<R, void, false, P1, P2, P3, P4, void>>(functionPointer); } ///< Creates a new Functor with the given function-pointer 604 template <class R, class P1, class P2, class P3> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2, P3)) { return std::make_shared<FunctorTemplate<R, void, false, P1, P2, P3, void, void>>(functionPointer); } ///< Creates a new Functor with the given function-pointer 605 template <class R, class P1, class P2> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2)) { return std::make_shared<FunctorTemplate<R, void, false, P1, P2, void, void, void>>(functionPointer); } ///< Creates a new Functor with the given function-pointer 606 template <class R, class P1> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1)) { return std::make_shared<FunctorTemplate<R, void, false, P1, void, void, void, void>>(functionPointer); } ///< Creates a new Functor with the given function-pointer 607 template <class R> inline FunctorStaticPtr createFunctor(R (*functionPointer)()) { return std::make_shared<FunctorTemplate<R, void, false, void, void, void, void, void>>(functionPointer); } ///< Creates a new Functor with the given function-pointer 568 template <class R, class O, class OO, class... Params> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(Params...), OO* object) { return std::make_shared<FunctorTemplate<R, O, false, Params...>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 569 template <class R, class O, class OO, class... Params> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(Params...) const, OO* object) { return std::make_shared<FunctorTemplate<R, O, true, Params...>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 570 571 template <class R, class O, class... Params> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(Params...)) { return std::make_shared<FunctorTemplate<R, O, false, Params...>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 572 template <class R, class O, class... Params> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(Params...) const) { return std::make_shared<FunctorTemplate<R, O, true, Params...>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 573 574 template <class R, class... Params> inline FunctorStaticPtr createFunctor(R (*functionPointer)(Params...)) { return std::make_shared<FunctorTemplate<R, void, false, Params...>>(functionPointer); } ///< Creates a new Functor with the given function-pointer 608 575 } 609 576
Note: See TracChangeset
for help on using the changeset viewer.