This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: std::string allocator
- From: "Stefan Olsson" <stefan at garcio dot com>
- To: Paolo Carlini <pcarlini at suse dot de>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Mon, 06 Mar 2006 16:57:16 +0100
- Subject: Re: std::string allocator
- References: <440C5729.4040100@suse.de>
Hi Paolo,
well, it doesn't seem that way - or else I'm doing something really wrong/wierd. I did the _very_ ugly test of adding a printf( "%d ", __n * sizeof(_Tp)) in the allocate (line 660 something) method of mt_alloc and it doesn't show up on strings - it does report usage on all other types (vectors, lists etc...).
I.e. compiling this little app will not generate any calls visible by the printf:
#include <string>
int main() {
std::string foo = "this is a test";
return 0;
}
Brgds
----- Original Message -----
Paolo Carlini wrote:
> Stefan Olsson wrote:
>
> >Hi folks,
> >
> >back with a new allocator related issue. Downloaded 4.1.0 and compiled with:
> >--enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --host=i386-redhat-linux --enable-libstdcxx-allocator=mt --enable-languages=c,c++
> >
> >This way I can enjoy the performance of mt_alloc without having to specify it every time (or rather set up a global define for each type). Not quite though...
> >...the std::string is defined in bits/stringfwd.h as:
> >typedef basic_string<char> string;
> >
> >
> Then string uses std::allocator<_CharT>, and since you passed
> --enable-libstdcxx-allocator=mt at build time, the implementation of
> std::allocator *is* mt_allocator:
>
> template<typename _Tp>
> class allocator: public __glibcxx_base_allocator<_Tp>
> ...
>
> I don't understand...
>
> Paolo.
>
Stefan Olsson
Chief Technical Officer
Office: +46 (0)40 978350
Fax: +46 (0)40 978360
Mobile: +46 (0)702 216050
E-mail: stefan@garcio.com
Garcio AB
Södra Promenaden 55
211 38 Malmö
Sweden
The information contained in this communication is intended solely for the use
of the individual or entity to whom it is addressed and others authorized to
receive it. It may contain confidential or legally privileged information.
If you are not the intended recipient you are hereby notified that any
disclosure, copying, distribution or taking any action in reliance on the
contents of this information is strictly prohibited and may be unlawful.
If you have received this communication in error, please notify us immediately
by responding to this email and then delete it from your system. Garcio AB is
neither liable for the proper and complete transmission of the information
contained in this communication nor for any delay in its receipt.