/docs/MyDocs

To get this branch, use:
bzr branch http://darksoft.org/webbzr/docs/MyDocs

« back to all changes in this revision

Viewing changes to Development/languages/C/Core/stl/allocators.txt

  • Committer: Suren A. Chilingaryan
  • Date: 2009-04-09 03:21:08 UTC
  • Revision ID: csa@dside.dyndns.org-20090409032108-w4edamdh4adrgdu3
import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
template <class T> allocator {
 
2
    T value_type; size_t size_type; ptrdiff_t difference_type;
 
3
    pointer; const_pointer; reference; const_reference;
 
4
    pinter address(reference r);
 
5
 
 
6
    pointer allocate(size_type n, allocator<void)::const_pointer hint = 0);
 
7
    void deallocate(pointer p, size_type n);  // p is not destroyed
 
8
    
 
9
    void construct(pointer p, const T& val); // p initialized by val
 
10
    void destroy(pointer p); // destroy's p, but do not deallocate
 
11
    
 
12
    size_type max_size();
 
13
    
 
14
    template<typename U>
 
15
    struct rebind { typedef allocator<U> other; };
 
16
}
 
17
 
 
18
* allocator<void)::const_pointer is equivalent of const void *
 
19
* hint is implementation dependent. For example, an allocator might try to 
 
20
allocate space for related object on the same page in a paging system.
 
21
* rebind is used to allow an allocator to allocate objects of arbitrary type
 
22
    typedef A::rebind<string>::other string_alloc;
 
23
    string_alloc alloc;
 
24
 
 
25
 
 
26
 
 
27
 
 
28
 
 
29
Uninitialized space
 
30
 pair<T*, ptrdiff_t> get_temporary_buffer(ptrdiff_t n);
 
31
    allocates 'n' or more objects of type 'T'. returns pointer to first 
 
32
    uninitialized space and the number of objects of type 'T' that will fit
 
33
    into the space.
 
34
 void return_temporary_buffer(T*);
 
35
 
 
36
 uninitialized_copy(first, last, Res); // copy into res
 
37
 uninitialized_fill(first, last, val);
 
38
 uninitialized_fill_n(firts, n, val);
 
39
 
 
 
b'\\ No newline at end of file'