Wrapper Technique in STLport
Considerable 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.
For example: #ifdef _STLP_DEFAULT_TYPE_PARAM template <class T, class Alloc = alloc> #else # define vector __vector template <class T, class Alloc> #endif class vector { public: ...... #ifdef _STLP_DEFAULT_TYPE_PARAM define __vector__ vector # else template <class T> class vector : public __vector__<T,alloc> { ..... #define __vector__ __vector # endif /* _STLP_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: | |
Table of Contents | |
Copyright 2001 by STLport |