[C++] Własny allocator + argumenty konstruktora + kontenery STL
Ostatnio zmodyfikowano 2012-04-20 17:14
DejaVu Temat założony przez niniejszego użytkownika |
[C++] Własny allocator + argumenty konstruktora + kontenery STL » 2012-04-20 15:10:56 Czy można stworzyć własny alokator, który będzie spełniał wymogi alokatora (pod kątem użycia w kontenerach STL) i jednocześnie będzie możliwość określenia argumentów jakie przyjmuje konstruktor tak, by była możliwość przekazania skonfigurowanego alokatora do kontenera STL?
/edit:
Dobra - znalazłem już:
typedef std::allocator < int > AlokatorT; typedef std::list < int, AlokatorT > KontenerT; KontenerT kontener = KontenerT( AlokatorT() );
Przy tworzeniu kontenera można określić argumenty konstruktora. |
|
DejaVu Temat założony przez niniejszego użytkownika |
» 2012-04-20 17:14:03 Coś niespecjalnie chce działać ten patent...
[0037BA18] Allocator( IAllocator& f_allocator ) | m_pAllocator = 003779E8
[0037392C] CPY( const Allocator& copy = 0037BA18 ) | m_pAllocator = 003779E8
[00373914] CPY( const Allocator& copy = 0037392C ) | m_pAllocator = 003779E8
[003738F8] CPY( const Allocator& copy = 00373914 ) | m_pAllocator = 003779E8
[003738E0] CPY( const Allocator& copy = 003738F8 ) | m_pAllocator = 003779E8
[0037BA20] CPY( const Allocator<U>& copy = 003738E0 ) | m_pAllocator = 003779E8
[0037BA20] allocate(...) | m_pAllocator = 003779E8
[003738E0] ~Allocator() | m_pAllocator = 003779E8
[0037BA24] CPY( const Allocator<U>& copy = 003738F8 ) | m_pAllocator = 003779E8
[003738F8] ~Allocator() | m_pAllocator = 003779E8
[0037BA28] CPY( const Allocator<U>& copy = 00373914 ) | m_pAllocator = 003779E8
[00373914] ~Allocator() | m_pAllocator = 003779E8
[0037BA2C] CPY( const Allocator& copy = 0037392C ) | m_pAllocator = 003779E8
[0037392C] ~Allocator() | m_pAllocator = 003779E8
[0037BA24] allocate(...) | m_pAllocator = 003779E8
[003779C0] Allocator() | m_pAllocator = 00000000
[00373930] Allocator() | m_pAllocator = 00000000
[00373918] CPY( const Allocator& copy = 00373930 ) | m_pAllocator = 00000000
[003738FC] CPY( const Allocator& copy = 00373918 ) | m_pAllocator = 00000000
[003738E4] CPY( const Allocator& copy = 003738FC ) | m_pAllocator = 00000000
[003779C8] CPY( const Allocator<U>& copy = 003738E4 ) | m_pAllocator = 00000000
[003779C8] allocate(...) | m_pAllocator = 00000000
Przy pierwszej alokacji pamięci m_pAlloator = NULL .
class CBla { typedef int DaneT; typedef Allocator < DaneT > AllocatorT; typedef std::list < DaneT, AllocatorT > ItemsT; AllocatorT m_allocator; ItemsT m_items; CBla() : m_allocator( m_system ) , m_items( m_allocator ) { } };
/edit:
Dobra - jednak działa :P wywoływałem inny konstruktor w klasie CBla, w którym nie było tych linijek co w podanym kodzie. |
|
« 1 » |