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.
STLport uses wrapper technique to work around that:
Full functionality for 'container' is implemented via class '__container__'.

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:
_STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS switch is introduced for user to take control of wrappers behavior with classes that have more than one default template argument. With this switch defined, STLport will use minimum set of default arguments on template classes that have more than one - for example map<>, set<>. This is supposed to help compiling existing standard code which use shortest notation.

Here is the list of compilers that cannot handle dependant default template parameters:
SunPro CC, BC++ 4.52, VC++ 4.2, xlC 3.1.4, DEC C++ 5.5, Visual Age C++ 3.0.


Table of Contents


Copyright 2001 by STLport