iffl  1.3.4
Implements Intrusive Flat Forward List container
iffl::flat_forward_list_traits< T > Class Template Reference

traits for an elements that are in the flat forward list More...

#include <iffl_list.h>

Detailed Description

template<typename T>
class iffl::flat_forward_list_traits< T >

traits for an elements that are in the flat forward list

Flat forward list element types are PODs defined in the headers that we often times cannot change, like OS headers, but we need to be able to define methods that would help container operate on them. For instance we need a universal way how to find offset of the next element regardless of how it is calculated for a particular type. Specialization of this class provides a group of functions that help with that. User of the collection is responsible for defining traits for the type he wants to use in the container.

This is the only method required by flat_forward_list_iterator. Returns offset to the next element or 0 if this is the last element.

constexpr static size_t get_next_offset(char const *buffer) noexcept;

This method is required for flat_forward_list_validate algorithm Minimum number of bytes to be able to safely query offset to next and safely examine other fields.

constexpr static size_t minimum_size() noexcept;

This method is required for flat_forward_list_validate algorithm Validates that variable data fits in the buffer

constexpr static bool validate(size_t buffer_size, char const *buffer) noexcept;

This method is used by flat_forward_list container to update offset to the next element. size can be 0 if this element is last or above zero for any other element.

constexpr static void set_next_offset(char *buffer, size_t size) noexcept

Specifies alignment requirements for the type. When provided then every newly added element will have proper alignment. Elements that already were in the buffer can be not properly aligned. If this member does not exist then aligned is assumed to be 1 byte

constexpr static size_t const alignment{ TYPE_ALIGNMENT };

This method is used by flat_forward_list. It calculates size of element, but it should not use next element offset, and instead it should calculate size based on the data this element contains. It is used when we append new element to the container, and need to update offset to the next on the element that used to be last. In that case offset to the next is determined by calling this method. Another example that uses this method is shrink_to_fit.

constexpr static size_t get_size(char const *buffer) noexcept

Examples: flat_forward_list_traits<FLAT_FORWARD_LIST_TEST> @ test\iffl_tests.cpp flat_forward_list_traits<FILE_FULL_EA_INFORMATION> @ test\iffl_es_usecase.cpp flat_forward_list_traits<long_long_array_list_entry> @ test\iffl_c_api_usecase.cpp


The documentation for this class was generated from the following file: