ChipMaster's trial hacks on C++CMS starting with v1.2.1. Not sure I'll follow on with the v2 since it looks to be breaking and mostly frivolous.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

104 lines
3.5 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (C) 2008-2012 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
  4. //
  5. // See accompanying file COPYING.TXT file for licensing details.
  6. //
  7. ///////////////////////////////////////////////////////////////////////////////
  8. #ifndef CPPCMS_UTIL_MEM_BIND_H
  9. #define CPPCMS_UTIL_MEM_BIND_H
  10. namespace cppcms { namespace util {
  11. /// \cond INTERNAL
  12. namespace details {
  13. template<typename C,typename P>
  14. struct binder0 {
  15. void (C::*member)();
  16. P object;
  17. void operator()() const { ((*object).*member)(); }
  18. };
  19. template<typename C,typename P,typename P1>
  20. struct binder1 {
  21. void (C::*member)(P1);
  22. P object;
  23. void operator()(P1 p1) const { ((*object).*member)(p1); }
  24. };
  25. template<typename C,typename P,typename P1,typename P2>
  26. struct binder2 {
  27. void (C::*member)(P1,P2);
  28. P object;
  29. void operator()(P1 p1,P2 p2) const { ((*object).*member)(p1,p2); }
  30. };
  31. template<typename C,typename P,typename P1,typename P2,typename P3>
  32. struct binder3 {
  33. void (C::*member)(P1,P2,P3);
  34. P object;
  35. void operator()(P1 p1,P2 p2,P3 p3) const { ((*object).*member)(p1,p2,p3); }
  36. };
  37. template<typename C,typename P,typename P1,typename P2,typename P3,typename P4>
  38. struct binder4 {
  39. void (C::*member)(P1,P2,P3,P4);
  40. P object;
  41. void operator()(P1 p1,P2 p2,P3 p3,P4 p4) const { ((*object).*member)(p1,p2,p3,p4); }
  42. };
  43. }
  44. /// \endcond
  45. ///
  46. /// Bind a member function \a mem of object referenced by a pointer \a obj creating a functional
  47. /// object that has an member function void operator()() const and calls obj->mem()
  48. ///
  49. template<typename C,typename P>
  50. details::binder0<C,P> mem_bind(void (C::*mem)(),P obj)
  51. {
  52. details::binder0<C,P> tmp={mem,obj};
  53. return tmp;
  54. }
  55. ///
  56. /// Bind a member function \a mem of object referenced by a pointer \a obj creating a functional
  57. /// object that has an member function void operator()(P1 p) const and calls obj->mem(p)
  58. ///
  59. template<typename C,typename P,typename P1>
  60. details::binder1<C,P,P1> mem_bind(void (C::*mem)(P1),P obj)
  61. {
  62. details::binder1<C,P,P1> tmp={mem,obj};
  63. return tmp;
  64. }
  65. ///
  66. /// Bind a member function \a mem of object referenced by a pointer \a obj creating a functional
  67. /// object that has an member function void operator()(P1 p1,P2 p2) const and calls obj->mem(p1,p2)
  68. ///
  69. template<typename C,typename P,typename P1,typename P2>
  70. details::binder2<C,P,P1,P2> mem_bind(void (C::*mem)(P1,P2),P obj)
  71. {
  72. details::binder2<C,P,P1,P2> tmp={mem,obj};
  73. return tmp;
  74. }
  75. ///
  76. /// Bind a member function \a mem of object referenced by a pointer \a obj creating a functional
  77. /// object that has an member function void operator()(P1 p1,P2 p2,P3 p3) const and calls obj->mem(p1,p2,p3)
  78. ///
  79. template<typename C,typename P,typename P1,typename P2,typename P3>
  80. details::binder3<C,P,P1,P2,P3> mem_bind(void (C::*mem)(P1,P2,P3),P obj)
  81. {
  82. details::binder3<C,P,P1,P2,P3> tmp={mem,obj};
  83. return tmp;
  84. }
  85. ///
  86. /// Bind a member function \a mem of object referenced by a pointer \a obj creating a functional
  87. /// object that has an member function void operator()(P1 p1,P2 p2,P3 p3,P4 ) const and calls obj->mem(p1,p2,p3,p4)
  88. ///
  89. template<typename C,typename P,typename P1,typename P2,typename P3,typename P4>
  90. details::binder4<C,P,P1,P2,P3,P4> mem_bind(void (C::*mem)(P1,P2,P3,P4),P obj)
  91. {
  92. details::binder4<C,P,P1,P2,P3,P4> tmp={mem,obj};
  93. return tmp;
  94. }
  95. } } // cppcms::util
  96. #endif