Class allocator

Synopsis

#include <include/EASTL/allocator.h>

class EASTL_API allocator

Description

allocator

In this allocator class, note that it is not templated on any type and instead it simply allocates blocks of memory much like the C malloc and free functions. It can be thought of as similar to C++ std::allocator<char>. The flags parameter has meaning that is specific to the allocation

C++11's std::allocator (20.6.9) doesn't have a move constructor or assignment operator. This is possibly because std::allocators are associated with types instead of as instances. The potential non-equivalance of C++ std::allocator instances has been a source of some acknowledged design problems. We don't implement support for move construction or assignment in eastl::allocator, but users can define their own allocators which do have move functions and the eastl containers are compatible with such allocators (i.e. nothing unexpected will happen).

Mentioned in

Methods

allocator overload
allocate overload
deallocate
get_name
operator=
set_name

Source

Lines 51-71 in include/EASTL/allocator.h.

class EASTL_API allocator
{
public:
    EASTL_ALLOCATOR_EXPLICIT allocator(const char* pName = EASTL_NAME_VAL(EASTL_ALLOCATOR_DEFAULT_NAME));
    allocator(const allocator& x);
    allocator(const allocator& x, const char* pName);
    allocator& operator=(const allocator& x);
    void* allocate(size_t n, int flags = 0);
    void* allocate(size_t n, size_t alignment, size_t offset, int flags = 0);
    void  deallocate(void* p, size_t n);
    const char* get_name() const;
    void        set_name(const char* pName);
protected:
    #if EASTL_NAME_ENABLED
        const char* mpName; // Debug name, used to track memory.
    #endif
};





Add Discussion as Guest

Log in