?? functionptr.hpp
字號(hào):
/* The following code example is taken from the book * "C++ Templates - The Complete Guide" * by David Vandevoorde and Nicolai M. Josuttis, Addison-Wesley, 2002 * * (C) Copyright David Vandevoorde and Nicolai M. Josuttis 2002. * Permission to copy, use, modify, sell and distribute this software * is granted provided this copyright notice appears in all copies. * This software is provided "as is" without express or implied * warranty, and with no claim as to its suitability for any purpose. */#include "forwardparam.hpp"#include "functionptrt.hpp"template<typename RT, typename P1 = void, typename P2 = void, typename P3 = void>class FunctionPtr { private: typedef typename FunctionPtrT<RT,P1,P2,P3>::Type FuncPtr; // the encapsulated pointer: FuncPtr fptr; public: // to fit in our framework: enum { NumParams = FunctionPtrT<RT,P1,P2,P3>::NumParams }; typedef RT ReturnT; typedef P1 Param1T; typedef P2 Param2T; typedef P3 Param3T; // constructor: FunctionPtr(FuncPtr ptr) : fptr(ptr) { } // ``function calls'': RT operator()() { return fptr(); } RT operator()(typename ForwardParamT<P1>::Type a1) { return fptr(a1); } RT operator()(typename ForwardParamT<P1>::Type a1, typename ForwardParamT<P2>::Type a2) { return fptr(a1, a2); } RT operator()(typename ForwardParamT<P1>::Type a1, typename ForwardParamT<P2>::Type a2, typename ForwardParamT<P2>::Type a3) { return fptr(a1, a2, a3); }};
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -