memory
|
This is the documentation of foonathan/memory
.
For a quick start, read the Tutorial or skim the examples at the Github page. The concepts of this library are defined are here.
New allocator concepts:
RawAllocator
that is similar to an Allocator
but easier to use and writeBlockAllocator
that is an allocator for huge memory blocksSeveral implementations:
heap_/malloc_/new_allocator
alloca()
in the form of temporary_allocator
Adapters, wrappers and storage classes:
allocator_traits
allowing Allocator
s as RawAllocator
sstd_allocator
to make a RawAllocator
an Allocator
againallocator_deleter
classes for smart pointersallocator_reference
and other storage classesIn addition:
See example/
for more.
This library can be used as [CMake] subdirectory. It is tested on GCC 4.7-4.9, Clang 3.4-3.5 and Visual Studio 2013. Newer versions should work too.
git submodule add https://github.com/foonathan/memory ext/memory
and git submodule update --init --recursive
.add_subdirectory(ext/memory)
or whatever your local path is to make it available in CMake.target_link_libraries(your_target PUBLIC foonathan_memory)
to link this library and setups the include search path.add_subdirectory()
and call comp_target_features(your_target PUBLIC CPP11)
.Note: If during CMake you see an error message that compatibility is not on the newest version, run git submodule update --recursive --remote
to force the compatiblity submodule of memory to update to the latest version.
You can also install the library:
cmake -DCMAKE_BUILD_TYPE="buildtype" -DFOONATHAN_MEMORY_BUILD_EXAMPLES=OFF -DFOONATHAN_MEMORY_BUILD_TESTS=OFF .
inside the library sources.cmake --build . -- install
to install the library under ${CMAKE_INSTALL_PREFIX}
.Debug
, RelWithDebInfo
and Release
or custom names).The use an installed library:
find_package(foonathan_memory major.minor REQUIRED)
to find the library.target_link_libraries(your_target PUBLIC foonathan_memory)
and activate C++11 to link to the library.See https://memory.foonathan.net/md_doc_installation.html for a detailed guide.
This documentation is written in a similar way as the C++ standard itself, although not that formal.
Concepts are documented using the names of the template parameters, for example the following class:
It takes two template parameters, the first must model the Tracker concept, the second the RawAllocator concept.
Unless explicitly stated otherwise, it is not allowed to call a function that modifies state from two different threads. Functions that modify state are non-const
member functions, functions taking a non-const
reference to objects or functions where it is explictly documented that they change some hidden state.
If a function is documented as noexcept
, it does not throw anything. Otherwise it has a Throws: clause specifying what it throws, or if it is a forwarding function, the information can be found there (see below).
If a class is described as RawAllocator it automatically has certain semantically information which are not explictly mentioned. This is especially true for the member functions of an allocator_traits specialization.
If a function is described as returning the value of another function or forwarding to it, it implicitly has the requirements and effects from the called function and can also throw the same things.