Common C++ calling types based on the parameter type and usage:
Use | In | Out | In-out | |
Common C++ calling types based on para-meter type and use |
Mono-morphic | const T p const T& p | return T; T& p | T& p |
Poly-morphic | const T& p | return T*; T*& p | T*& p |
Monomorphic in parameters include const T p and const T& p. Whether you choose a const T or a const T& usually depends on the size of the class. Returning a T or using a T& p parameter depends on the size of the class and the number of out parameters.
Table 2 and Table 3 show the typical syntax of caller stub and dispatcher stubs based on these parameter types.
Usage | In | Out | In-Out | |
Caller stub syntax |
Mono-morphic | p >>= stream; SendRequest(); | SendRequest(); p <<= stream; | p >>= stream; SendRequest(); p << stream; |
Poly-morphic | stream.FlattenPointer(&p); SendRequest; | SendRequest(); p = (T*)(stream.Resurrect()); | stream.FlattenPointer(&p); SendRequest(); delete p; p = (T*)(stream.Resurrect()); |
Usage | In | Out | In-Out | |
Dispatcher stub syntax |
Mono-morphic | T p; p <<= stream; implementation | T p; implementation p >>= transport; | T p; p <<= stream; implementation p >>= transport; |
Poly-morphic | T* p; p = (T*)(stream.Resurrect()); implementation delete p; | T* p; implementation stream.FlattenPointer(&p); delete p; | T* p; p = (T*)(stream.Resurrect()); implementation stream.FlattenPointer(&p); delete p; |