Skip to content

Latest commit

 

History

History
609 lines (405 loc) · 13.2 KB

tied_sequence.md

File metadata and controls

609 lines (405 loc) · 13.2 KB

tied_sequence

#include <flat_map/tied_sequence.hpp>

template <typename... Sequences>
class tied_sequence;

Requirements

Example

flat_map (and its variants), in this library, provides Array of Structure (AOS) style by default. Use tied_sequence for Container template parameter to achieve Structure of Array (SOA) style flat map.

#include <flat_map/flat_map.hpp>
#include <flat_map/tied_sequence.hpp>

flat_map::flat_map<
  /* Key */ int,
  /* T */ HugeValueType,
  /* Compare */ std::less<int>,
  /* Container */ flat_map::tied_sequence<std::vector<int>, std::deque<HugeValueType>>
> tied_map;

Member types

using value_type = std::tuple<typename Sequences::value_type...>;
using allocator_type = /* unspecified */;
using size_type = std::size_t;
using difference_type = std::ptrdiff_t;
using reference = std::tuple<typename Sequences::reference...>;
using const_reference = std::tuple<typename Sequences::const_reference...>;
using pointer = std::tuple<typename Sequences::pointer...>;
using const_pointer = std::tuple<typename Sequences::const_pointer...>;
using iterator = /* unspecified */;
using const_iterator = /* unspecified */;
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;

Constructors

constexpr tied_sequence();

Exceptions

No exception only if for all sequences meet all of

  • std::is_nothrow_default_constructible_v<Sequence> == true
constexpr explicit tied_sequence(allocator_type const& alloc) noexcept;
constexpr explicit tied_sequence(typename Sequences::allocator_type const&... alloc) noexcept;

Construct sequences form corresponding allocator.

constexpr tied_sequence(size_type count, value_type const& value);
constexpr tied_sequence(size_type count, value_type const& value, allocator_type const& alloc);
constexpr tied_sequence(size_type count, value_type const& value, typename Sequences::allocator_type const&... alloc);
constexpr tied_sequence(size_type count);
constexpr tied_sequence(size_type count, allocator_type const& alloc);
constexpr tied_sequence(size_type count, typename Sequences::allocator_type const&... alloc);

Construct sequence containers holding count copies of value or default-value.

template <typename InputIterator>
constexpr tied_sequence(InputIterator first, InputIterator last);

template <typename InputIterator>
constexpr tied_sequence(InputIterator first, InputIterator last, allocator_type const& alloc);

template <typename InputIterator>
constexpr tied_sequence(InputIterator first, InputIterator last, typename Sequences::allocator_type const&... alloc);

Construct containers from [first, last).

Pre requirements

InputIterator should meet InputIterator.

constexpr tied_sequence(tied_sequence const& other);
constexpr tied_sequence(tied_sequence const& other, allocator_type const& alloc);
constexpr tied_sequence(tied_sequence const& other, typename Sequences::allocator_type const&... alloc);

Copy from other.

constexpr tied_sequence(tied_sequence&& other);
constexpr tied_sequence(tied_sequence&& other, allocator_type const& alloc);
constexpr tied_sequence(tied_sequence&& other, typename Sequences::allocator_type const&... alloc);

Move entire elements from other.

constexpr tied_sequence(std::initializer_list<value_type> init);
constexpr tied_sequence(std::initializer_list<value_type> init, allocator_type const& alloc);
constexpr tied_sequence(std::initializer_list<value_type> init, typename Sequences::allocator_type const&... alloc);

Construct from init.

Assignments

constexpr tied_sequence& operator=(tied_sequence const& other);

Copy from other.

constexpr tied_sequence& operator=(tied_sequence&& other);

Move entire elements from other.

Exceptions

No exception only if each sequences meet all of

  • std::allocator_traits<typename Sequence::allocator_type>::propagate_on_container_move_assignment::value == true and
  • std::allocator_traits<typename Sequence::allocator_type>::is_always_equal::value == true
constexpr tied_sequence& operator=(std::initializer_list<value_type> ilist);

Complexity

Linear.

constexpr void assign(size_type count, value_type const& value);

Replace with count copies of value for each sequences.

Complexity

Linear.

template <typename InputIterator>
constexpr void assign(InputIterator first, InputIterator last);

Replace containers from [first, last).

Pre requirements

InputIterator should meet InputIterator.

constexpr void assign(std::initializer_list<value_type> ilist);

Allocator

constexpr allocator_type get_allocator() const noexcept;

Element access

at

constexpr reference at(size_type pos);
constexpr const_reference at(size_type pos);

Complexity

Worse case of Sequences.

operator[]

constexpr reference operator[](size_type pos);
constexpr const_reference operator[](size_type pos);

Complexity

Worse case of Sequences.

front

constexpr reference front();
constexpr const_reference front();

Complexity

Worse case of Sequences.

back

constexpr reference back() { return *std::prev(end()); }
constexpr const_reference back() const { return *std::prev(end()); }

Complexity

Worse case of Sequences.

data

constexpr pointer data() noexcept;
constexpr const_pointer data() const noexcept;

Available only if every sequences provide data().

Iterators

begin

constexpr iterator begin() noexcept;
constexpr const_iterator begin() noexcept;

cbegin

constexpr const_iterator cbegin() const noexcept;

end

constexpr iterator end() noexcept;
constexpr const_iterator end() const noexcept;

cend

constexpr const_iterator cend() const noexcept;

rbegin

constexpr reverse_iterator rbegin() noexcept;
constexpr const_reverse_iterator rbegin() const noexcept;

crbegin

constexpr const_reverse_iterator crbegin() const noexcept;

rend

constexpr reverse_iterator rend() noexcept;
constexpr const_reverse_iterator rend() const noexcept;

crend

constexpr const_reverse_iterator crend() const noexcept;

Capacity

empty

constexpr bool empty() const noexcept;

size

constexpr size_t size() const noexcept;

max_size

constexpr size_t max_size() const noexcept;

reserve

constexpr void reserve(size_type new_cap);

Available only if every sequences provide reserve().

capacity

constexpr size_type capacity() const noexcept;

Available only if every sequences provide capacity().

shrink_to_fit

constexpr void shrink_to_fit();

Available only if every sequences provide shrink_to_fit().

Modifiers

clear

constexpr void clear() noexcept;

insert

constexpr iterator insert(const_iterator pos, value_type const& value);
constexpr iterator insert(const_iterator pos, value_type&& value);

Insert a value.

Exceptions Safety

Those functions doesn't guarantee exception neutrality.

constexpr iterator insert(const_iterator pos, size_type count, value_type const& value);

Insert count copies of value.

Exceptions Safety

This function doesn't guarantee exception neutrality.

template <typename InputIterator>
constexpr iterator insert(const_iterator pos, InputIterator first, InputIterator last);

Insert values from [first, last).

Exceptions Safety

This functions doesn't guarantee exception neutrality.

constexpr iterator insert(const_iterator pos, std::initializer_list<value_type> ilist);

Insert values from ilist.

Exceptions Safety

This functions doesn't guarantee exception neutrality.

emplace

template <typename... Args>
constexpr iterator emplace(const_iterator pos, Args&&... args);

Equivalent to insert(pos, value_type(std::forward<Args>(args)...)).

Exceptions Safety

This functions doesn't guarantee exception neutrality.

template <typename... Args>
constexpr iterator emplace(const_iterator pos, std::piecewise_construct_t, Args&&... args);

Insert new elements with piecewise construction.

Exceptions Safety

This functions doesn't guarantee exception neutrality.

erase

constexpr iterator erase(const_iterator pos);
constexpr iterator erase(const_iterator first, const_iterator last);

Return value

An iterator that next to erased elements.

Exceptions Safety

This functions doesn't guarantee exception neutrality.

push_back

constexpr void push_back(value_type const& value);
constexpr void push_back(value_type&& value);

Exceptions Safety

This functions doesn't guarantee exception neutrality.

emplace_back

template <typename... Args>
constexpr reference emplace_back(Args&&... args);

Return value

Reference to inserted value.

Exceptions Safety

This functions doesn't guarantee exception neutrality.

pop_back

constexpr void pop_back();

Exceptions Safety

This functions doesn't guarantee exception neutrality.

resize

constexpr void resize(size_type count);
constexpr void resize(size_type count, value_type const& value);

Exceptions Safety

This functions doesn't guarantee exception neutrality.

swap

constexpr void swap(tied_sequence& other);

Swap elements with other.

Exceptions

No exception only if for all sequences meet all of

  • std::allocator_traits<typename Sequence::allocator_type>::propagate_on_container_swap::value == true
  • std::allocator_traits<typename Sequence::allocator_type>::is_always_equal::value == true

Non member functions

operator==

template <typename... Sequences>
constexpr bool operator==(tied_sequence<Sequences...> const& lhs, tied_sequence<Sequences...> const& rhs);

operator!=

template <typename... Sequences>
bool operator!=(tied_sequence<Sequences...> const& lhs, tied_sequence<Sequences...> const& rhs);

Standard

This function is removed if

  • __cpp_impl_three_way_comparison is defined, and
  • __cpp_lib_three_way_comparison is defined.

operator<

template <typename... Sequences>
bool operator<(tied_sequence<Sequences...> const& lhs, tied_sequence<Sequences...> const& rhs);

Standard

This function is removed if

  • __cpp_impl_three_way_comparison is defined, and
  • __cpp_lib_three_way_comparison is defined.

operator<=

template <typename... Sequences>
bool operator<=(tied_sequence<Sequences...> const& lhs, tied_sequence<Sequences...> const& rhs);

Standard

This function is removed if

  • __cpp_impl_three_way_comparison is defined, and
  • __cpp_lib_three_way_comparison is defined.

operator>

template <typename... Sequences>
bool operator>(tied_sequence<Sequences...> const& lhs, tied_sequence<Sequences...> const& rhs);

Standard

This function is removed if

  • __cpp_impl_three_way_comparison is defined, and
  • __cpp_lib_three_way_comparison is defined.

operator>=

template <typename... Sequences>
bool operator>=(tied_sequence<Sequences...> const& lhs, tied_sequence<Sequences...> const& rhs);

Standard

This function is removed if

  • __cpp_impl_three_way_comparison is defined, and
  • __cpp_lib_three_way_comparison is defined.

operator<=>

template <typename... Sequences>
constexpr /* see below */ operator<=>(tied_sequence<Sequences...> const& lhs, tied_sequence<Sequences...> const& rhs);

Return value

std::lexicographical_compare_three_way(lhs.begin(), lhs.end(), rhs.begin(), rhs.end())

Standard

This function is defined only if

  • __cpp_impl_three_way_comparison is defined, and
  • __cpp_lib_three_way_comparison is defined.

swap

template <typename... Sequences>
constexpr void swap(tied_sequence<Sequences...> const& lhs, tied_sequence<Sequences...> const& rhs);

Exceptions

No exception only if noexcept(lhs.swap(rhs)) is true.

erase

template <typename... Sequences, typename U>
constexpr typename tied_sequence<Sequences...>::size_type erase(tied_sequence<Sequences...>& c, U const& value);

Erase every elements which equivalent to value.

erase_if

template <typename... Sequences, typename Pred>
constexpr typename tied_sequence<Sequences...>::size_type erase_if(tied_sequence<Sequences...>& c, Pred pred);

Erase every elements which pred returned true.

forward_allocator

template <typename... Allocators>
/* unspecified */ forward_allocator(Allocators&&... alloc);

Forward allocators as tied_sequence::allocator_type.