|
|
Wrapper Technique in STLportConsiderable point of non-portability was the lack of default template class parameters in many compilers. C++ template syntax doesn't allow an easy way to hide that behind any macro magic.STLport uses wrapper technique to work around that: For example: #ifdef __STL_DEFAULT_TYPE_PARAM template <class T, class Alloc = alloc> #else # define vector __vector template <class T, class Alloc> #endif class vector { public: ...... #ifdef __STL_DEFAULT_TYPE_PARAM define __vector__ vector # else template <class T> class vector : public __vector__<T,alloc> { ..... #define __vector__ __vector # endif /* __STL_DEFAULT_TYPE_PARAM */So, you are provided with two versions of container: with and without default parameters. It buys you a way to access full functionality while not breaking code using the short notation. If you wish to specify the allocator parameter, use __vector__. For default alloc parameter, use vector. I would recommend that you #define some alias for __vector__, to be able to switch easily. If you don't use different allocators, don't bother. New in STLport 3.2: Here is the list of compilers that cannot handle dependant
default template parameters: |
Copyright � 1999,2000 by Boris Fomitchev. Last modified: July 14, 2000 |