emlabcpp
modern opinionated embedded C++ library
emlabcpp::static_storage< T, N > Struct Template Reference

Continuous data container that can contain N of uninitialized elements. More...

#include <static_storage.h>

Public Types

using value_type = T
 
using reference = T &
 
using const_reference = T const &
 
using pointer = T *
 
using const_pointer = T const *
 
using size_type = std::size_t
 

Public Member Functions

constexpr pointer data () noexcept
 Returns pointer to first item of the storage. More...
 
constexpr const_pointer data () const noexcept
 Returns pointer to first item of the storage. More...
 
template<typename... Args>
constexpr T & emplace_item (size_type const i, Args &&... args) noexcept(std::is_nothrow_constructible_v< T, Args... >)
 Constructs an item at position i with arguments args... More...
 
constexpr void delete_item (size_type const i) noexcept(std::is_nothrow_destructible_v< T >)
 Deconstructs an item at position i. More...
 
constexpr reference operator[] (size_type const i) noexcept
 Provides a reference to item at position i. More...
 
constexpr const_reference operator[] (size_type const i) const noexcept
 Provides a reference to item at position i. More...
 

Static Public Attributes

static constexpr std::size_t capacity = N
 

Detailed Description

template<typename T, std::size_t N>
struct emlabcpp::static_storage< T, N >

Continuous data container that can contain N of uninitialized elements.

Bookkeeping (what item is initialized and what is not) is up to owner of this structure.

Member Typedef Documentation

◆ const_pointer

template<typename T , std::size_t N>
using emlabcpp::static_storage< T, N >::const_pointer = T const*

◆ const_reference

template<typename T , std::size_t N>
using emlabcpp::static_storage< T, N >::const_reference = T const&

◆ pointer

template<typename T , std::size_t N>
using emlabcpp::static_storage< T, N >::pointer = T*

◆ reference

template<typename T , std::size_t N>
using emlabcpp::static_storage< T, N >::reference = T&

◆ size_type

template<typename T , std::size_t N>
using emlabcpp::static_storage< T, N >::size_type = std::size_t

◆ value_type

template<typename T , std::size_t N>
using emlabcpp::static_storage< T, N >::value_type = T

Member Function Documentation

◆ data() [1/2]

template<typename T , std::size_t N>
constexpr const_pointer emlabcpp::static_storage< T, N >::data ( ) const
inlineconstexprnoexcept

Returns pointer to first item of the storage.

◆ data() [2/2]

template<typename T , std::size_t N>
constexpr pointer emlabcpp::static_storage< T, N >::data ( )
inlineconstexprnoexcept

Returns pointer to first item of the storage.

◆ delete_item()

template<typename T , std::size_t N>
constexpr void emlabcpp::static_storage< T, N >::delete_item ( size_type const  i)
inlineconstexprnoexcept

Deconstructs an item at position i.

References emlabcpp::static_storage< T, N >::data().

◆ emplace_item()

template<typename T , std::size_t N>
template<typename... Args>
constexpr T& emlabcpp::static_storage< T, N >::emplace_item ( size_type const  i,
Args &&...  args 
)
inlineconstexprnoexcept

Constructs an item at position i with arguments args...

References emlabcpp::args, and emlabcpp::static_storage< T, N >::data().

◆ operator[]() [1/2]

template<typename T , std::size_t N>
constexpr const_reference emlabcpp::static_storage< T, N >::operator[] ( size_type const  i) const
inlineconstexprnoexcept

Provides a reference to item at position i.

References emlabcpp::static_storage< T, N >::data().

◆ operator[]() [2/2]

template<typename T , std::size_t N>
constexpr reference emlabcpp::static_storage< T, N >::operator[] ( size_type const  i)
inlineconstexprnoexcept

Provides a reference to item at position i.

References emlabcpp::static_storage< T, N >::data().

Member Data Documentation

◆ capacity

template<typename T , std::size_t N>
constexpr std::size_t emlabcpp::static_storage< T, N >::capacity = N
staticconstexpr

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