iffl  1.3.4
Implements Intrusive Flat Forward List container
Public Types | Static Public Member Functions | Static Public Attributes | List of all members
iffl::flat_forward_list_traits_traits< T, TT > Class Template Reference

traits for flat_forward_list_traits More...

#include <iffl_list.h>

Public Types

using value_type = T
 
using type_traits = TT
 
using has_minimum_size_t = iffl::mpl::is_detected< has_minimum_size_mfn, type_traits >
 Uses detect idiom with has_minimum_size_mfn to find if traits implemented minimum_size. More...
 
using has_get_size_t = iffl::mpl::is_detected< has_get_size_mfn, type_traits >
 Uses detect idiom with has_get_size_mfn to find if traits implemented get_size. More...
 
using has_next_offset_t = iffl::mpl::is_detected< has_next_offset_mfn, type_traits >
 Uses detect idiom with has_next_offset_mfn to find if traits implemented get_next_offset. More...
 
using can_set_next_offset_t = iffl::mpl::is_detected< can_set_next_offset_mfn, type_traits >
 Uses detect idiom with can_set_next_offset_mfn to find if traits implemented set_next_offset. More...
 
using can_validate_t = iffl::mpl::is_detected< can_validate_mfn, type_traits >
 Uses detect idiom with can_validate_mfn to find if traits implemented validate. More...
 
using has_alignment_t = iffl::mpl::is_detected< has_alignment_mfn, type_traits >
 Uses detect idiom with has_alignment_mfn to find if traits implemented validate. More...
 
using range_t = range_with_alighment< alignment >
 Specialization of range_with_alighment for this type alignment.
 
using size_with_padding_t = size_with_padding< alignment >
 Specialization of size_with_padding for this type alignment.
 
using offset_with_aligment_t = offset_with_aligment< alignment >
 Specialization of offset_with_aligment for this type alignment.
 

Static Public Member Functions

static value_typeptr_to_t (void *ptr)
 Casts buffer pointer to a pointer to the element type. More...
 
static value_type const * ptr_to_t (void const *ptr)
 Casts buffer pointer to a pointer to the element type. More...
 
static value_typeptr_to_t (char *ptr)
 Casts buffer pointer to a pointer to the element type. More...
 
static value_type const * ptr_to_t (char const *ptr)
 Casts buffer pointer to a pointer to the element type. More...
 
static value_typeptr_to_t (unsigned char *ptr)
 Casts buffer pointer to a pointer to the element type. More...
 
static value_type const * ptr_to_t (unsigned char const *ptr)
 Casts buffer pointer to a pointer to the element type. More...
 
static constexpr size_t minimum_size () noexcept
 returns minimum valid element size
 
static constexpr size_t get_alignment () noexcept
 If traits defined alignment then size of alignment, and 1 otherwise.
 
static constexpr size_t roundup_to_alignment (size_t s) noexcept
 If traits defined alignment then s padded to alignment, or unchanged value of s otherwise. More...
 
static constexpr size_with_padding_t get_size (char const *buffer) noexcept
 Asks type traits to calculate element size. More...
 
static constexpr bool validate (size_t buffer_size, T const &buffer) noexcept
 Asks type traits to validate element. More...
 
static constexpr size_t get_next_offset (char const *buffer) noexcept
 Returns next element offset. More...
 
static constexpr void set_next_offset (char *buffer, size_t size) noexcept
 Sets next element offset. More...
 
static void print_traits_info () noexcept
 Prints information about what traits_traits discovered about traits class.
 

Static Public Attributes

static constexpr auto const has_minimum_size_v { iffl::mpl::is_detected_v < has_minimum_size_mfn, type_traits> }
 Instance of has_minimum_size_t. More...
 
static constexpr auto const has_get_size_v { iffl::mpl::is_detected_v < has_get_size_mfn, type_traits> }
 Instance of has_get_size_t. More...
 
static constexpr auto const has_next_offset_v { iffl::mpl::is_detected_v < has_next_offset_mfn, type_traits> }
 Instance of has_next_offset_t. More...
 
static constexpr auto const can_set_next_offset_v { iffl::mpl::is_detected_v < can_set_next_offset_mfn, type_traits> }
 Instance of can_set_next_offset_t. More...
 
static constexpr auto const can_validate_v { iffl::mpl::is_detected_v < can_validate_mfn, type_traits> }
 Instance of can_validate_t. More...
 
static constexpr auto const has_alignment_v { iffl::mpl::is_detected_v < has_alignment_mfn, type_traits> }
 Instance of has_alignment_t. More...
 
static constexpr size_t const alignment { get_alignment() }
 Defines static constexpr member that with value that has alignment requirements of elements.
 

Detailed Description

template<typename T, typename TT = flat_forward_list_traits<T>>
class iffl::flat_forward_list_traits_traits< T, TT >

traits for flat_forward_list_traits

Template Parameters
T- element header type
TT- type traits

I know, traits of traits does sounds ridicules, but this is exactly what this class is. Given flat_forward_list_traits instantiation, or a class that you want to use as traits for your flat_forward_list element types, it detects what methods are implemented by this trait so in the rest of algorithms and containers we can use this helper, and avoid rewriting same complicated and nasty machinery. In other words traits might be missing some methods, and traits_traits will implement these missing parts providing a uniform interface.

How to use:

using my_traits_traits = flat_forward_list_traits_traits<my_type, my_traits>;

For example:

If traits provide us a way to get value of the next element offset for a type then use it, otherwise ask it to calculate next element offset from its own size If traits provides alignment member then we will use in calculation of padding, otherwise calculations of padding will use 1 byte alignment.

if constexpr (my_traits_traits::has_next_offset_v) {
my_traits::get_next_offset(buffer)
} else {
my_traits::get_size(buffer)
}

Member Typedef Documentation

◆ can_set_next_offset_t

template<typename T , typename TT = flat_forward_list_traits<T>>
iffl::flat_forward_list_traits_traits< T, TT >::can_set_next_offset_t

Uses detect idiom with can_set_next_offset_mfn to find if traits implemented set_next_offset.

If traits have get_next_offset then can_set_next_offset_t is std::true_type otherwise std::false_type

◆ can_validate_t

template<typename T , typename TT = flat_forward_list_traits<T>>
iffl::flat_forward_list_traits_traits< T, TT >::can_validate_t

Uses detect idiom with can_validate_mfn to find if traits implemented validate.

If traits have get_next_offset then can_validate_t is std::true_type otherwise std::false_type

◆ has_alignment_t

template<typename T , typename TT = flat_forward_list_traits<T>>
iffl::flat_forward_list_traits_traits< T, TT >::has_alignment_t

Uses detect idiom with has_alignment_mfn to find if traits implemented validate.

If traits have traits::alignment static variable then has_alignment_t is std::true_type otherwise std::false_type

◆ has_get_size_t

template<typename T , typename TT = flat_forward_list_traits<T>>
iffl::flat_forward_list_traits_traits< T, TT >::has_get_size_t

Uses detect idiom with has_get_size_mfn to find if traits implemented get_size.

If traits have get_size then has_get_size_t is std::true_type otherwise std::false_type

◆ has_minimum_size_t

template<typename T , typename TT = flat_forward_list_traits<T>>
iffl::flat_forward_list_traits_traits< T, TT >::has_minimum_size_t

Uses detect idiom with has_minimum_size_mfn to find if traits implemented minimum_size.

If traits have minimum_size then has_minimum_size_t is std::true_type otherwise std::false_type

◆ has_next_offset_t

template<typename T , typename TT = flat_forward_list_traits<T>>
iffl::flat_forward_list_traits_traits< T, TT >::has_next_offset_t

Uses detect idiom with has_next_offset_mfn to find if traits implemented get_next_offset.

If traits have get_next_offset then has_next_offset_t is std::true_type otherwise std::false_type

◆ type_traits

template<typename T , typename TT = flat_forward_list_traits<T>>
iffl::flat_forward_list_traits_traits< T, TT >::type_traits

!brief alias for the traits

◆ value_type

template<typename T , typename TT = flat_forward_list_traits<T>>
iffl::flat_forward_list_traits_traits< T, TT >::value_type

!brief alias for the value type

Member Function Documentation

◆ get_next_offset()

template<typename T , typename TT = flat_forward_list_traits<T>>
static constexpr size_t iffl::flat_forward_list_traits_traits< T, TT >::get_next_offset ( char const *  buffer)
inlinestaticnoexcept

Returns next element offset.

Parameters
buffer- pointer to the beginning of the element
Returns
For the types that support query for the next element offset method returns get_next_offset, otherwise it returns element size

◆ get_size()

template<typename T , typename TT = flat_forward_list_traits<T>>
static constexpr size_with_padding_t iffl::flat_forward_list_traits_traits< T, TT >::get_size ( char const *  buffer)
inlinestaticnoexcept

Asks type traits to calculate element size.

Parameters
buffer- pointer to the beginning of the element
Returns
element size wrapped into size_with_padding_t

◆ ptr_to_t() [1/6]

template<typename T , typename TT = flat_forward_list_traits<T>>
static value_type* iffl::flat_forward_list_traits_traits< T, TT >::ptr_to_t ( void *  ptr)
inlinestatic

Casts buffer pointer to a pointer to the element type.

Parameters
ptr- pointer to a buffer

◆ ptr_to_t() [2/6]

template<typename T , typename TT = flat_forward_list_traits<T>>
static value_type const* iffl::flat_forward_list_traits_traits< T, TT >::ptr_to_t ( void const *  ptr)
inlinestatic

Casts buffer pointer to a pointer to the element type.

Parameters
ptr- pointer to a buffer

◆ ptr_to_t() [3/6]

template<typename T , typename TT = flat_forward_list_traits<T>>
static value_type* iffl::flat_forward_list_traits_traits< T, TT >::ptr_to_t ( char *  ptr)
inlinestatic

Casts buffer pointer to a pointer to the element type.

Parameters
ptr- pointer to a buffer

◆ ptr_to_t() [4/6]

template<typename T , typename TT = flat_forward_list_traits<T>>
static value_type const* iffl::flat_forward_list_traits_traits< T, TT >::ptr_to_t ( char const *  ptr)
inlinestatic

Casts buffer pointer to a pointer to the element type.

Parameters
ptr- pointer to a buffer

◆ ptr_to_t() [5/6]

template<typename T , typename TT = flat_forward_list_traits<T>>
static value_type* iffl::flat_forward_list_traits_traits< T, TT >::ptr_to_t ( unsigned char *  ptr)
inlinestatic

Casts buffer pointer to a pointer to the element type.

Parameters
ptr- pointer to a buffer

◆ ptr_to_t() [6/6]

template<typename T , typename TT = flat_forward_list_traits<T>>
static value_type const* iffl::flat_forward_list_traits_traits< T, TT >::ptr_to_t ( unsigned char const *  ptr)
inlinestatic

Casts buffer pointer to a pointer to the element type.

Parameters
ptr- pointer to a buffer

◆ roundup_to_alignment()

template<typename T , typename TT = flat_forward_list_traits<T>>
static constexpr size_t iffl::flat_forward_list_traits_traits< T, TT >::roundup_to_alignment ( size_t  s)
inlinestaticnoexcept

If traits defined alignment then s padded to alignment, or unchanged value of s otherwise.

Parameters
s- value that we are rounding up
Returns
Value of s padded to alignment

◆ set_next_offset()

template<typename T , typename TT = flat_forward_list_traits<T>>
static constexpr void iffl::flat_forward_list_traits_traits< T, TT >::set_next_offset ( char *  buffer,
size_t  size 
)
inlinestaticnoexcept

Sets next element offset.

Types that support setting next element offset must also support get_next_offset.

Parameters
buffer- pointer to the beginning of the element
size- offset of the next element

◆ validate()

template<typename T , typename TT = flat_forward_list_traits<T>>
static constexpr bool iffl::flat_forward_list_traits_traits< T, TT >::validate ( size_t  buffer_size,
T const &  buffer 
)
inlinestaticnoexcept

Asks type traits to validate element.

If traits do not have validate method

Parameters
buffer_size- size of the buffer used by this element
buffer- pointer to the beginning of the element
Returns
element size wrapped into size_with_padding_t

Member Data Documentation

◆ can_set_next_offset_v

template<typename T , typename TT = flat_forward_list_traits<T>>
constexpr auto const iffl::flat_forward_list_traits_traits< T, TT >::can_set_next_offset_v { iffl::mpl::is_detected_v < can_set_next_offset_mfn, type_traits> }
static

Instance of can_set_next_offset_t.

can_set_next_offset_v is std::true_type{} otherwise std::false_type{}

◆ can_validate_v

template<typename T , typename TT = flat_forward_list_traits<T>>
constexpr auto const iffl::flat_forward_list_traits_traits< T, TT >::can_validate_v { iffl::mpl::is_detected_v < can_validate_mfn, type_traits> }
static

Instance of can_validate_t.

can_validate_v is std::true_type{} otherwise std::false_type{}

◆ has_alignment_v

template<typename T , typename TT = flat_forward_list_traits<T>>
constexpr auto const iffl::flat_forward_list_traits_traits< T, TT >::has_alignment_v { iffl::mpl::is_detected_v < has_alignment_mfn, type_traits> }
static

Instance of has_alignment_t.

has_alignment_v is std::true_type{} otherwise std::false_type{}

◆ has_get_size_v

template<typename T , typename TT = flat_forward_list_traits<T>>
constexpr auto const iffl::flat_forward_list_traits_traits< T, TT >::has_get_size_v { iffl::mpl::is_detected_v < has_get_size_mfn, type_traits> }
static

Instance of has_get_size_t.

has_get_size_v is std::true_type{} otherwise std::false_type{}

◆ has_minimum_size_v

template<typename T , typename TT = flat_forward_list_traits<T>>
constexpr auto const iffl::flat_forward_list_traits_traits< T, TT >::has_minimum_size_v { iffl::mpl::is_detected_v < has_minimum_size_mfn, type_traits> }
static

Instance of has_minimum_size_t.

has_minimum_size_v is std::true_type{} otherwise std::false_type{}

◆ has_next_offset_v

template<typename T , typename TT = flat_forward_list_traits<T>>
constexpr auto const iffl::flat_forward_list_traits_traits< T, TT >::has_next_offset_v { iffl::mpl::is_detected_v < has_next_offset_mfn, type_traits> }
static

Instance of has_next_offset_t.

has_next_offset_v is std::true_type{} otherwise std::false_type{}


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