This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: default allocator templ arg for map and multimap


could you tell me the reason for the two const in the map and multimap :
_Alloc = allocator<pair<const _Key, const _Tp> > >
isntead of 
_Alloc = allocator<pair<const _Key, _Tp> > >
?

scott snyder wrote:
> 
> >The __STL_DEFAULT_ALLOCATOR macro is an obsolete compabitility
> >hack.  Please do submit a patch without it, and without the
> >__STL_LIMITED_DEFAULT_TEMPLATES hack either.
> 
> Ok, i'm appending a patch that does that.
> 
> >(For extra credit, eliminate both from all declarations -- but don't
> >hold up the fix on that account.)
> 
> Following that is a patch that removes all instances of those macros
> (plus __STL_DEPENDENT_DEFAULT_TMPL) that i could find from the library.
> 
> [Aside: I also noticed that the hash_map and hash_multimap have the
> same problem with the allocator default that map and multimap did...]
> 
> sss
> 
> 2000-04-10  scott snyder  <snyder@fnal.gov>
> 
>         * stl/bits/stl_map.h (class map): Fix default for _Alloc template
>         parameter.  Get rid of use of __STL_DEFAULT_ALLOCATOR and
>         __STL_LIMITED_DEFAULT_TEMPLATES macros.
>         * stl/bits/stl_multimap.h (class multimap): Likewise.  Get rid of
>         use of __STL_DEPENDENT_DEFAULT_TMPL macro.
> 
> Index: stl/bits/stl_map.h
> ===================================================================
> RCS file: /cvs/libstdc++/libstdc++/stl/bits/stl_map.h,v
> retrieving revision 1.7
> diff -u -p -r1.7 stl_map.h
> --- stl_map.h   1999/05/05 00:39:22     1.7
> +++ stl_map.h   2000/04/11 04:28:02
> @@ -38,13 +38,8 @@ __STL_BEGIN_NAMESPACE
>  #pragma set woff 1375
>  #endif
> 
> -#ifndef __STL_LIMITED_DEFAULT_TEMPLATES
>  template <class _Key, class _Tp, class _Compare = less<_Key>,
> -          class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >
> -#else
> -template <class _Key, class _Tp, class _Compare,
> -          class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >
> -#endif
> +          class _Alloc = allocator<pair<const _Key, const _Tp> > >
>  class map {
>  public:
> 
> Index: stl/bits/stl_multimap.h
> ===================================================================
> RCS file: /cvs/libstdc++/libstdc++/stl/bits/stl_multimap.h,v
> retrieving revision 1.8
> diff -u -p -r1.8 stl_multimap.h
> --- stl_multimap.h      1999/05/05 00:39:23     1.8
> +++ stl_multimap.h      2000/04/11 04:28:02
> @@ -41,8 +41,8 @@ __STL_BEGIN_NAMESPACE
>  // Forward declaration of operators < and ==, needed for friend declaration.
> 
>  template <class _Key, class _Tp,
> -          class _Compare __STL_DEPENDENT_DEFAULT_TMPL(less<_Key>),
> -          class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >
> +          class _Compare = less<_Key>,
> +          class _Alloc = allocator<pair<const _Key, const _Tp> > >
>  class multimap;
> 
>  template <class _Key, class _Tp, class _Compare, class _Alloc>


 -- lfarkas
 "The only thing worse than not knowing the truth is
  ruining the bliss of ignorance."

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]