Topic: Const-qualified class type as Allocator?


Author: algrant@myrealbox.com (Al Grant)
Date: Thu, 19 Aug 2004 15:49:04 GMT
Raw View
sebormartin@netscape.net (Martin Sebor) wrote in message news:<a220a90a.0408181720.60ab8e5e@posting.google.com>...
> algrant@myrealbox.com (Al Grant) wrote in message news:<5765b025.0408180538.7cfbef90@posting.google.com>...
> > Assuming T is a legal Allocator type, is const T also legal?
>
> Not anymore. See
> http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#274

Surely that's not the same thing?  That refers to qualifiers on
T in std::allocator<T> and asks about Table 31 that describes
"the requirements on types manipulated through allocators".
(Though the resolution refers to Table 32, the 'any type' which
it suggests correcting is actually in Table 31 - is this a typo?)
My question is about allocator types themselves, as constrained
by Table 32, "the requirements on allocator types".  E.g.

  typedef const allocator< pair<string, int> > MyAlloc;
  typedef map<string, int, less<string>, MyAlloc > MyMap;

Is MyAlloc an acceptable allocator type?

(Your issue would seem to be about whether

  typedef allocator< const pair<string, int> > MyAlloc;

is an acceptable allocator type.)

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: algrant@myrealbox.com (Al Grant)
Date: Wed, 18 Aug 2004 14:44:17 GMT
Raw View
Assuming T is a legal Allocator type, is const T also legal?
Nothing in 20.1.5 appears to forbid this.  But some STLs
derive directly from the Allocator type, and a const-qualified
class type is not valid as a base class specifier, even though
several compilers don't pick up on it (Comeau and g++ fault it;
VC++, Sun C++ and HP aC++ allow it).

Does this mean that any STL wishing to derive from allocator
types must use a template trick to remove qualifiers, and that
an STL that didn't would be broken?

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: sebormartin@netscape.net (Martin Sebor)
Date: Thu, 19 Aug 2004 01:51:49 GMT
Raw View
algrant@myrealbox.com (Al Grant) wrote in message news:<5765b025.0408180538.7cfbef90@posting.google.com>...
> Assuming T is a legal Allocator type, is const T also legal?

Not anymore. See
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#274

Martin

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]