This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
_Alloc_hider?
- From: Jeffrey Walton <noloader at gmail dot com>
- To: GCC Users List <gcc-help at gcc dot gnu dot org>
- Date: Mon, 15 Aug 2011 19:30:52 -0400
- Subject: _Alloc_hider?
- Reply-to: noloader at gmail dot com
Hi All,
I'm testing a custom allocator. The allocator works well with vector,
but fails to link with basic_string (see below).
I looked through Stroustrup and could not find info on _Alloc_hider.
Searching online doesn't reveal much either (perhaps I have not waded
through enough irrelevant fodder). I did find [1], buts its just
DoOxygen with no real content (its written in STL terseness with no
comments).
I believe I need another constructor, but I'm not sure what it takes
or how to write it:
inline explicit zallocator() { }
inline ~zallocator() { }
inline explicit zallocator(zallocator const&) { }
template<typename U>
inline explicit zallocator(zallocator<U> const&) { }
How does one one provided an allocator for use by a basic_string?
Jeff
[1] http://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-4.3/a00073.html
==================================================================
typedef basic_string< char, char_traits<char>, zallocator<char> > String;
String str = "Goodbye, world";
$ g++ -g3 -ggdb -O0 AllocTest.cpp -o AllocTest.exe
In file included from /usr/include/c++/4.5/string:53:0,
from /usr/include/c++/4.5/bits/locale_classes.h:42,
from /usr/include/c++/4.5/bits/ios_base.h:43,
from /usr/include/c++/4.5/ios:43,
from /usr/include/c++/4.5/ostream:40,
from /usr/include/c++/4.5/iostream:40,
from SecAllocTest.cpp:3:
/usr/include/c++/4.5/bits/basic_string.h: In member function
‘allocator_type std::basic_string<_CharT, _Traits,
_Alloc>::get_allocator() const [with _CharT = char, _Traits =
std::char_traits<char>, _Alloc = zallocator<char>, allocator_type =
zallocator<char>]’:
/usr/include/c++/4.5/bits/basic_string.h:525:9: instantiated from
‘std::basic_string<_CharT, _Traits, _Alloc>::~basic_string() [with
_CharT = char, _Traits = std::char_traits<char>, _Alloc =
zallocator<char>]’
SecAllocTest.cpp:103:22: instantiated from here
/usr/include/c++/4.5/bits/basic_string.h:1741:16: error: no matching
function for call to
‘zallocator<char>::zallocator(std::basic_string<char,
std::char_traits<char>, zallocator<char> >::_Alloc_hider&)’