mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-16 00:46:03 +08:00
* Add ranges * Initial Hugo setup * Work in progress * Added selection for local or remote site * Updated to 'light' theme * Changed to using Hextra Hugo theme * Changed to using Hextra Hugo theme * Changed to Hextra Hugo theme * Change to Hextra Hugo theme * Updated Hugo setup. * Updated Hugo setup. # Conflicts: # docs/releases/_index.md * Work in progress * Added new fonts Added new documentation * Latest documentation updates * Latest documentation updates # Conflicts: # docs/containers/array.md # docs/containers/array_view.md # docs/containers/array_wrapper.md # docs/containers/bip_buffer_spsc_atomic.md # docs/containers/bitset.md # docs/containers/indirect_vector.md # docs/containers/vector.md # docs/getting-started/compilers.md * Added bloom_filter markdown doc * Added more documentation Updated CSS for light and dark modes * Fixed some menus Added mode documentation files * Updated CSS rules Added badges to home page Added uniqur_ptr + pool tutorial * Fixed formatting on the home page markdown Modified light amd dark code formatting * Updated unique_ptr-with-pool * Added container and shared message tutorials * Updates to documentation * Added const_multimap * Updated source-formatting.md * Added initial raw text files form Web site editor * Innore coverage build directory * Exported raw text documentation files from the web site editor * Hugo updates * Added Hugo intalation and markdown descriptions * More addition to the documentation * Added closure.md and updates to delegate.md * Added format.md * Added documentation for etl::delegate_observable, etl::function, Base64 codec * Added io_port documentation * Added basic_format_spec * Added documentation for string_stream and string utilities. * Added more documentation Updated the documentation CSS * Added documentation for clocks, day, duration * Added more documentation for chrono classes Updated callouts * More chrono documentation * Completed chrono documentation * Maths functions documentation * Completed maths documentation * Completed maths documentation * Completed maths documentation * Completed maths documentation * Added multiple documentation files * Added iterator.md * Added debug_count.md and versions.md * Added debug_count.md and versions.md * Added more documentation * More documentation * Added some design pattern documentation Modified some of the layout files Modified the About documentation * Converted more documentation pages Modified the site CSS * Added more documentation Moced some documentation files to new directories * Added more documentation Tweaks to CSS * Added callback_timer_deferred_locked documentation * Added callback_timer_locked documentation * More documentation updates * More documentation updates * More documentation updates * New documentation files. Harmonised file name format * New documentation files. * Multiple document updates * Multiple document updates * Final conversion of web pages * Updates before PR * Updates before PR * Updates before PR # Conflicts: # docs/blog/_index.md * Final pre PR updates * Updates to message framework documentation * Renamed directory * Fix spelling * Added author and date to blog files Moved documentation files merged from development * Fixed 'Description' typo * Fix typos # Conflicts: # docs/IO/io_port.md # docs/containers/sets/const-multiset.md # docs/containers/sets/const-set.md # docs/maths/correlation.md # docs/maths/gamma.md * Renamed two files to lower case * Minor renaming * Added author and date * Updated callout on bresenham_line.md Added support for showing the ETL version on the documentation first page, by copying the version.txt file as a hugo asset. Updated the Python 'update_release.py' to copy 'version.txt' * Replace space in filename with hyphen. Added more information to hugo-commands.md * Replace space in filename with hyphen. Added more information to hugo-commands.md # Conflicts: # docs/getting-started/view-the-docs-locally/hugo-commands.md * Added a link to pseudo_moving_average.md * Updated title pages for groups * Fixed missing 404 for non-existent pages * Fixed coordinate variable names in the 'Calculating the intersection' example --------- Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de> Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.com> Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.co.uk>
854 lines
17 KiB
Markdown
854 lines
17 KiB
Markdown
---
|
|
title: "tuple"
|
|
---
|
|
|
|
{{< callout type="info">}}
|
|
Header: `tuple.h`
|
|
Similar to: `std::tuple`
|
|
{{< /callout >}}
|
|
|
|
C++11 and above.
|
|
A fixed-size collection of heterogeneous values.
|
|
|
|
```cpp
|
|
template <typename... TTypes>
|
|
class tuple
|
|
```
|
|
|
|
## Traits
|
|
|
|
```cpp
|
|
template <typename T>
|
|
struct is_tuple
|
|
```
|
|
Type trait to check if a type is an `etl::tuple`
|
|
|
|
## Types
|
|
```cpp
|
|
using value_type = THead; ///< The type contained by this tuple.
|
|
using this_type = tuple<THead, TTail...>; ///< The type of this tuple.
|
|
using base_type = tuple<TTail...>; ///< The type of the base tuple.
|
|
using type_list = etl::type_list<THead, TTail...>; ///< The type list for this tuple.
|
|
using index_sequence_type = etl::make_index_sequence< number_of_types< THead, TTail...>()>; ///< The index_sequence type for this tuple.
|
|
```
|
|
|
|
## Constants
|
|
|
|
```cpp
|
|
inline constexpr private_tuple::ignore_t ignore;
|
|
```
|
|
From: C++17
|
|
|
|
---
|
|
|
|
```cpp
|
|
static constexpr private_tuple::ignore_t ignore;
|
|
```
|
|
Before: C++17
|
|
|
|
## Constructors
|
|
|
|
```cpp
|
|
ETL_CONSTEXPR14
|
|
tuple()
|
|
```
|
|
**Description**
|
|
Default constructor.
|
|
|
|
---
|
|
|
|
```cpp
|
|
ETL_CONSTEXPR14
|
|
tuple(const tuple<THead, TTail...>& other) = default;
|
|
```
|
|
**Description**
|
|
Copy constructor.
|
|
|
|
---
|
|
|
|
```cpp
|
|
ETL_CONSTEXPR14
|
|
tuple(tuple<THead, TTail...>&& other) = default;
|
|
```
|
|
**Description**
|
|
Move constructor.
|
|
|
|
---
|
|
|
|
```cpp
|
|
ETL_CONSTEXPR14
|
|
tuple& operator=(const tuple<THead, TTail...>& other) = default;
|
|
```
|
|
**Description**
|
|
Copy assignment.
|
|
|
|
---
|
|
|
|
```cpp
|
|
ETL_CONSTEXPR14
|
|
tuple& operator=(tuple<THead, TTail...>&& other) = default;
|
|
```
|
|
**Description**
|
|
Move assignment.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename... UTypes>
|
|
ETL_CONSTEXPR14
|
|
tuple(tuple<UTypes...>& other)
|
|
```
|
|
**Description**
|
|
Copy construct from lvalue reference tuple type.
|
|
Implicit conversion.
|
|
|
|
Enabled if:-
|
|
- The number of `UTypes` == number of `TTypes`.
|
|
- The number of `TTYpes` >= 1.
|
|
- `UTypes` are convertible to `TTypes`.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename... UTypes>
|
|
ETL_CONSTEXPR14
|
|
explicit tuple(tuple<UTypes...>& other)
|
|
```
|
|
**Description**
|
|
Copy construct from lvalue reference tuple type.
|
|
Explicit conversion.
|
|
|
|
Enabled if:-
|
|
- The number of `UTypes` == number of `TTypes`.
|
|
- The number of `TTYpes` >= 1.
|
|
- `UTypes` are **not** convertible to `TTypes`.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename... UTypes>
|
|
ETL_CONSTEXPR14
|
|
tuple(const tuple<UTypes...>& other)
|
|
```
|
|
**Description**
|
|
Copy construct from const lvalue reference tuple type.
|
|
Implicit conversion.
|
|
|
|
Enabled if:-
|
|
- The number of `UTypes` == number of `TTypes`.
|
|
- The number of `TTYpes` >= 1.
|
|
- `UTypes` are convertible to `TTypes`.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename... UTypes>
|
|
ETL_CONSTEXPR14
|
|
explicit tuple(const tuple<UTypes...>& other)
|
|
```
|
|
**Description**
|
|
Copy construct from const lvalue reference tuple type.
|
|
Explicit conversion.
|
|
|
|
Enabled if:-
|
|
- The number of `UTypes` == number of `TTypes`.
|
|
- The number of `TTYpes` >= 1.
|
|
- `UTypes` are **not** convertible to `TTypes`.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename... UTypes>
|
|
ETL_CONSTEXPR14
|
|
tuple(tuple<UHead, UTail...>&& other)
|
|
```
|
|
**Description**
|
|
Move construct from rvalue reference tuple type.
|
|
Implicit conversion
|
|
|
|
Enabled if:-
|
|
- The number of `UTypes` == number of `TTypes`.
|
|
- The number of `TTYpes` >= 1.
|
|
- `UTypes` are convertible to `TTypes`.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename... UTypes>
|
|
ETL_CONSTEXPR14
|
|
explicit tuple(tuple<UTypes...>&& other)
|
|
```
|
|
**Description**
|
|
Move construct from rvalue reference tuple type.
|
|
Explicit conversion.
|
|
|
|
Enabled if:-
|
|
- The number of `UTypes` == number of `TTypes`.
|
|
- The number of `TTYpes` >= 1.
|
|
- `UTypes` are **not** convertible to `TTypes`.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename... UTypes>
|
|
ETL_CONSTEXPR14
|
|
tuple(const tuple<UHead, UTail...>&& other)
|
|
```
|
|
**Description**
|
|
Move construct from const rvalue reference tuple type.
|
|
Implicit conversion
|
|
|
|
Enabled if:-
|
|
- The number of `UTypes` == number of `TTypes`.
|
|
- The number of `TTYpes` >= 1.
|
|
- `UTypes` are convertible to `TTypes`.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename... UTypes>
|
|
ETL_CONSTEXPR14
|
|
explicit tuple(const tuple<UTypes...>&& other)
|
|
```
|
|
**Description**
|
|
Move construct from const rvalue reference tuple type.
|
|
Explicit conversion.
|
|
|
|
Enabled if:-
|
|
- The number of `UTypes` == number of `TTypes`.
|
|
- The number of `TTYpes` >= 1.
|
|
- `UTypes` are **not** convertible to `TTypes`.
|
|
|
|
---
|
|
|
|
```cpp
|
|
ETL_CONSTEXPR14
|
|
tuple(const TTypes&... args)
|
|
```
|
|
**Description**
|
|
Construct from arguments.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename... UTypes>
|
|
ETL_CONSTEXPR14
|
|
tuple(UHead&& head, UTail&&... tail) ETL_NOEXCEPT
|
|
```
|
|
**Description**
|
|
Construct from arguments.
|
|
Implicit conversion.
|
|
|
|
Enabled if:-
|
|
- The number of `UTypes` == number of `TTypes`.
|
|
- The number of `TTYpes` >= 1.
|
|
- `UTypes` are not convertible to `TTypes`.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename... UTypes>
|
|
ETL_CONSTEXPR14
|
|
explicit tuple(UHead&& head, UTail&&... tail) ETL_NOEXCEPT
|
|
```
|
|
**Description**
|
|
Construct from arguments.
|
|
Explicit conversion.
|
|
|
|
Enabled if:-
|
|
- The number of `UTypes` == number of `TTypes`.
|
|
- The number of `TTYpes` >= 1.
|
|
- `UTypes` are **not** convertible to `TTypes`.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename U1, typename U2,
|
|
ETL_CONSTEXPR14
|
|
tuple(ETL_OR_STD::pair<U1, U2>& p) ETL_NOEXCEPT
|
|
```
|
|
**Description**
|
|
Construct from lvalue reference pair.
|
|
Implicit conversion.
|
|
|
|
Enabled if:-
|
|
- The number of `TTYpes` == 2.
|
|
- `U1` and `U2` are convertible to `TTypes`.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename U1, typename U2,
|
|
ETL_CONSTEXPR14
|
|
explicit tuple(ETL_OR_STD::pair<U1, U2>& p) ETL_NOEXCEPT
|
|
```
|
|
**Description**
|
|
Construct from lvalue reference pair.
|
|
Explicit conversion.
|
|
|
|
Enabled if:-
|
|
- The number of `TTYpes` == 2.
|
|
- `U1` or `U2` are not convertible to `TTypes`.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename U1, typename U2,
|
|
ETL_CONSTEXPR14
|
|
tuple(const ETL_OR_STD::pair<U1, U2>& p) ETL_NOEXCEPT
|
|
```
|
|
**Description**
|
|
Construct from const lvalue reference pair.
|
|
Implicit conversion.
|
|
|
|
Enabled if:-
|
|
- The number of `TTYpes` == 2.
|
|
- `U1` and `U2` are convertible to `TTypes`.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename U1, typename U2,
|
|
ETL_CONSTEXPR14
|
|
explicit tuple(const ETL_OR_STD::pair<U1, U2>& p) ETL_NOEXCEPT
|
|
```
|
|
**Description**
|
|
Construct from const lvalue reference pair.
|
|
Explicit conversion.
|
|
|
|
Enabled if:-
|
|
- The number of `TTYpes` == 2.
|
|
- `U1` or `U2` are not convertible to `TTypes`.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename U1, typename U2,
|
|
ETL_CONSTEXPR14
|
|
tuple(ETL_OR_STD::pair<U1, U2>&& p) ETL_NOEXCEPT
|
|
```
|
|
**Description**
|
|
Construct from rvalue reference pair.
|
|
Implicit conversion.
|
|
|
|
Enabled if:-
|
|
- The number of `TTYpes` == 2.
|
|
- `U1` and `U2` are convertible to `TTypes`.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename U1, typename U2,
|
|
ETL_CONSTEXPR14
|
|
explicit tuple(ETL_OR_STD::pair<U1, U2>&& p) ETL_NOEXCEPT
|
|
```
|
|
**Description**
|
|
Construct from rvalue reference pair.
|
|
Explicit conversion.
|
|
|
|
Enabled if:-
|
|
- The number of `TTYpes` == 2.
|
|
- `U1` or `U2` are not convertible to `TTypes`.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename U1, typename U2,
|
|
ETL_CONSTEXPR14
|
|
tuple(const ETL_OR_STD::pair<U1, U2>&& p) ETL_NOEXCEPT
|
|
```
|
|
**Description**
|
|
Construct from const rvalue reference pair.
|
|
Implicit conversion.
|
|
|
|
Enabled if:-
|
|
- The number of `TTYpes` == 2.
|
|
- `U1` and `U2` are convertible to `TTypes`.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename U1, typename U2,
|
|
ETL_CONSTEXPR14
|
|
explicit tuple(const ETL_OR_STD::pair<U1, U2>&& p) ETL_NOEXCEPT
|
|
```
|
|
**Description**
|
|
Construct from const rvalue reference pair.
|
|
Explicit conversion.
|
|
|
|
Enabled if:-
|
|
- The number of `TTYpes` == 2.
|
|
- `U1` or `U2` are not convertible to `TTypes`.
|
|
|
|
## Assignment
|
|
|
|
```cpp
|
|
template <typename... UTypes>
|
|
ETL_CONSTEXPR14
|
|
tuple& operator=(const tuple<UTypes...>& other)
|
|
```
|
|
**Description**
|
|
Copy assign from other tuple type.
|
|
|
|
Enabled if:-
|
|
- The number of `UTypes` == number of `TTypes`.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename... UTypes>
|
|
ETL_CONSTEXPR14
|
|
tuple& operator=(tuple<UTypes...>&& other)
|
|
```
|
|
**Description**
|
|
Move assign from other tuple type.
|
|
|
|
Enabled if:-
|
|
- The number of `UTypes` == number of `TTypes`.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename U1, typename U2>
|
|
ETL_CONSTEXPR14
|
|
tuple& operator=(ETL_OR_STD::pair<U1, U2>& p)
|
|
```
|
|
**Description**
|
|
Assign from lvalue pair tuple type.
|
|
|
|
Enabled if:-
|
|
- The number of `TTYpes` == 2.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename U1, typename U2>
|
|
ETL_CONSTEXPR14
|
|
tuple& operator=(const ETL_OR_STD::pair<U1, U2>& p)
|
|
```
|
|
**Description**
|
|
Assign from const lvalue pair tuple type.
|
|
|
|
Enabled if:-
|
|
- The number of `TTYpes` == 2.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename U1, typename U2>
|
|
ETL_CONSTEXPR14
|
|
tuple& operator=(ETL_OR_STD::pair<U1, U2>&& p)
|
|
```
|
|
**Description**
|
|
Assign from rvalue pair tuple type.
|
|
|
|
Enabled if:-
|
|
- The number of `TTYpes` == 2.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename U1, typename U2>
|
|
ETL_CONSTEXPR14
|
|
tuple& operator=(const ETL_OR_STD::pair<U1, U2>&& p)
|
|
```
|
|
**Description**
|
|
Assign from const rvalue pair tuple type.
|
|
|
|
Enabled if:-
|
|
- The number of `TTYpes` == 2.
|
|
|
|
## Other
|
|
|
|
```cpp
|
|
ETL_CONSTEXPR14
|
|
void swap(this_type& other)
|
|
```
|
|
**Description**
|
|
Swaps this tuple with another.
|
|
|
|
---
|
|
|
|
```cpp
|
|
ETL_NODISCARD
|
|
constexpr static size_t size()
|
|
```
|
|
**Description**
|
|
Returns the number of elements in the tuple.
|
|
|
|
## Template deduction guides
|
|
For C++17 and above.
|
|
|
|
```cpp
|
|
template <typename... TArgs>
|
|
tuple(TArgs... args) -> tuple<TArgs...>;
|
|
```
|
|
**Description**
|
|
From variadic arguments.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename T1, typename T2>
|
|
tuple(ETL_OR_STD::pair<T1, T2>) -> tuple<T1, T2>;
|
|
```
|
|
From a `pair`.
|
|
|
|
## Utility classes
|
|
|
|
```cpp
|
|
template <size_t Index, typename... TTypes>
|
|
struct tuple_element<Index, etl::tuple<TTypes...>>
|
|
```
|
|
**Description**
|
|
Gets the element type at `Index` in the tuple.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename... TTypes>
|
|
struct tuple_size<etl::tuple<TTypes...>>
|
|
```
|
|
**Description**
|
|
Gets the size of the tuple.
|
|
Derived from `etl::integral_constant<size_t, sizeof...(TTypes)>`.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename... TTypes>
|
|
struct common_type<etl::tuple<TTypes...>>
|
|
```
|
|
**Description**
|
|
Gets the common type of a tuple.
|
|
|
|
## Get an element
|
|
|
|
```cpp
|
|
template <size_t Index, typename... TTypes>
|
|
ETL_NODISCARD
|
|
ETL_CONSTEXPR14
|
|
etl::tuple_element_t<Index, etl::tuple<TTypes...>>& get(tuple<TTypes...>& t)
|
|
```
|
|
**Description**
|
|
Extracts the element at `Index` from the tuple.
|
|
`Index` must be an integer value in [`0`, `sizeof...(TTypes)`).
|
|
Returns a reference to the value.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <size_t Index, typename... TTypes>
|
|
ETL_NODISCARD
|
|
ETL_CONSTEXPR14
|
|
const etl::tuple_element_t<Index, etl::tuple<TTypes...>>& get(const tuple<TTypes...>& t)
|
|
```
|
|
**Description**
|
|
Extracts the element at `Index` from the tuple.
|
|
`Index` must be an integer value in [`0`, `sizeof...(TTypes)`).
|
|
Returns a const reference to the value.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <size_t Index, typename... TTypes>
|
|
ETL_NODISCARD
|
|
ETL_CONSTEXPR14
|
|
etl::tuple_element_t<Index, etl::tuple<TTypes...>>&& get(tuple<TTypes...>&& t)
|
|
```
|
|
**Description**
|
|
Extracts the element at `Index` from the tuple.
|
|
`Index` must be an integer value in [`0`, `sizeof...(TTypes)`).
|
|
Returns an rvalue reference.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <size_t Index, typename... TTypes>
|
|
ETL_NODISCARD
|
|
ETL_CONSTEXPR14
|
|
const etl::tuple_element_t<Index, etl::tuple<TTypes...>>&& get(const tuple<TTypes...>&& t)
|
|
```
|
|
**Description**
|
|
Extracts the element at `Index` from the tuple.
|
|
`Index` must be an integer value in [`0`, `sizeof...(TTypes)`).
|
|
Returns a const rvalue reference.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename T, typename... TTypes>
|
|
ETL_NODISCARD
|
|
ETL_CONSTEXPR14
|
|
T& get(tuple<TTypes...>& t)
|
|
```
|
|
**Description**
|
|
Extracts the element with type `T` from the tuple.
|
|
Static asserts if the tuple contains more than one `T`, or does not contain a `T` element.
|
|
Returns a reference to the value.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename T, typename... TTypes>
|
|
ETL_NODISCARD
|
|
ETL_CONSTEXPR14
|
|
const T& get(const tuple<TTypes...>& t)
|
|
```
|
|
**Description**
|
|
Extracts the element with type `T` from the tuple.
|
|
Static asserts if the tuple contains more than one `T`, or does not contain a `T` element.
|
|
Returns a const reference to the value.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename T, typename... TTypes>
|
|
ETL_NODISCARD
|
|
ETL_CONSTEXPR14
|
|
T&& get(tuple<TTypes...>&& t)
|
|
```
|
|
**Description**
|
|
Extracts the element with type `T` from the tuple.
|
|
Static asserts if the tuple contains more than one `T`, or does not contain a `T` element.
|
|
Returns an rvalue reference to the value.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename T, typename... TTypes>
|
|
ETL_NODISCARD
|
|
ETL_CONSTEXPR14
|
|
const T&& get(const tuple<TTypes...>&& t)
|
|
```
|
|
**Description**
|
|
Extracts the element with type `T` from the tuple.
|
|
Static asserts if the tuple contain more than one `T`, or does not contain a `T` element.
|
|
Returns a const rvalue reference to the value.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename... TTypes>
|
|
ETL_CONSTEXPR
|
|
etl::tuple<TTypes&...> tie(TTypes&... args)
|
|
```
|
|
**Description**
|
|
Create a tuple of references to the provided arguments.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename... TTypes>
|
|
ETL_NODISCARD
|
|
ETL_CONSTEXPR14
|
|
etl::tuple<etl::unwrap_ref_decay_t<TTypes>...> make_tuple(TTypes&&... args)
|
|
```
|
|
**Description**
|
|
Create a tuple from the provided arguments.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename TTuple, size_t... Indices>
|
|
ETL_NODISCARD
|
|
ETL_CONSTEXPR14
|
|
auto select_from_tuple(TTuple&& tuple,
|
|
etl::index_sequence<Indices...>)
|
|
-> etl::tuple<etl::tuple_element_t<Indices, etl::decay_t<TTuple>>...>
|
|
```
|
|
**Description**
|
|
Create a new tuple by selecting elements from another, given a run time index sequence.
|
|
Static asserts if the number of indices does not match the tuple size.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <size_t... Indices, typename TTuple>
|
|
ETL_NODISCARD
|
|
ETL_CONSTEXPR14
|
|
auto select_from_tuple(TTuple&& tuple)
|
|
-> etl::tuple<etl::tuple_element_t<Indices, etl::decay_t<TTuple>>...>
|
|
```
|
|
**Description**
|
|
Create a new tuple by selecting elements from another, given a template parameter index sequence.
|
|
Static asserts if the number of indices does not match the tuple size.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename... TTypes>
|
|
ETL_NODISCARD
|
|
ETL_CONSTEXPR14
|
|
etl::tuple<TTypes&&...> forward_as_tuple(TTypes&&... args)
|
|
```
|
|
**Description**
|
|
Forward the arguments as a tuple.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename... Tuples>
|
|
ETL_NODISCARD
|
|
ETL_CONSTEXPR14
|
|
auto tuple_cat(Tuples&&... t) -> Tuple
|
|
```
|
|
**Description**
|
|
Concatenate the list of tuples.
|
|
|
|
---
|
|
|
|
## If using the STL
|
|
|
|
Converts an etl::tuple to a std::tuple.
|
|
|
|
```cpp
|
|
template <typename... TTypes>
|
|
ETL_NODISCARD
|
|
ETL_CONSTEXPR14
|
|
auto to_std(const etl::tuple<TTypes...>& etl_tuple) -> std::tuple<etl::decay_t<TTypes>...>
|
|
```
|
|
**Description**
|
|
Converts a `const etl::tuple` to a `std::tuple`.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename... TTypes>
|
|
ETL_NODISCARD
|
|
ETL_CONSTEXPR14
|
|
auto to_std(etl::tuple<TTypes...>&& etl_tuple) -> std::tuple<etl::decay_t<TTypes>...>
|
|
```
|
|
**Description**
|
|
Converts an `etl::tuple` to a `std::tuple`.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename... TTypes>
|
|
ETL_NODISCARD
|
|
ETL_CONSTEXPR14
|
|
auto to_etl(const std::tuple<TTypes...>& std_tuple) -> etl::tuple<etl::decay_t<TTypes>...>
|
|
```
|
|
**Description**
|
|
Converts a `const std::tuple` to an `etl::tuple`.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename... TTypes>
|
|
ETL_NODISCARD
|
|
ETL_CONSTEXPR14
|
|
auto to_etl(std::tuple<TTypes...>&& std_tuple) -> etl::tuple<etl::decay_t<TTypes>...>
|
|
```
|
|
**Description**
|
|
Converts a `std::tuple` to an `etl::tuple`.
|
|
|
|
## Comparisons
|
|
|
|
```cpp
|
|
template <typename... TTypes, typename... UTypes>
|
|
ETL_NODISCARD
|
|
ETL_CONSTEXPR14
|
|
bool operator==(const etl::tuple<TTypes...>& lhs, const etl::tuple<UTypes...>& rhs)
|
|
```
|
|
**Description**
|
|
Equality operator.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename... TTypes, typename... UTypes>
|
|
ETL_NODISCARD
|
|
ETL_CONSTEXPR14
|
|
bool operator!=(const etl::tuple<TTypes...>& lhs, const etl::tuple<UTypes...>& rhs)
|
|
```
|
|
**Description**
|
|
Inequality operator.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename... TTypes, typename... UTypes>
|
|
ETL_NODISCARD
|
|
ETL_CONSTEXPR14
|
|
bool operator<(const etl::tuple<TTypes...>& lhs, const etl::tuple<UTypes...>& rhs)
|
|
```
|
|
**Description**
|
|
Less than operator.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename... TTypes, typename... UTypes>
|
|
ETL_NODISCARD
|
|
ETL_CONSTEXPR14
|
|
bool operator<=(const etl::tuple<TTypes...>& lhs, const etl::tuple<UTypes...>& rhs)
|
|
```
|
|
**Description**
|
|
Less than or equals operator.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename... TTypes, typename... UTypes>
|
|
ETL_NODISCARD
|
|
ETL_CONSTEXPR14
|
|
bool operator>(const etl::tuple<TTypes...>& lhs, const etl::tuple<UTypes...>& rhs)
|
|
```
|
|
**Description**
|
|
Greater than operator.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename... TTypes, typename... UTypes>
|
|
ETL_NODISCARD ETL_CONSTEXPR14 bool operator>=(const etl::tuple<TTypes...>& lhs, const etl::tuple<UTypes...>& rhs)
|
|
```
|
|
**Description**
|
|
Greater than or equals operator.
|
|
|
|
## Swap
|
|
|
|
```cpp
|
|
template <typename... TTypes>
|
|
ETL_CONSTEXPR14
|
|
void swap(etl::tuple<TTypes...>& lhs, etl::tuple<TTypes...>& rhs)
|
|
```
|
|
**Description**
|
|
Swap two tuples.
|
|
|
|
## Helpers
|
|
|
|
```cpp
|
|
template <typename... TTypes>
|
|
struct tuple_from_type_list<etl::type_list<TTypes...>>
|
|
```
|
|
**Description**
|
|
Helper to turn `etl::type_list<TList>` into `etl::tuple<TList>`
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <typename TTypeList>
|
|
using tuple_from_type_list_t = typename tuple_from_type_list<TTypeList>::type
|
|
```
|
|
|
|
## STL namespace definitions
|
|
|
|
```cpp
|
|
template <typename... Types>
|
|
struct tuple_size<etl::tuple<Types...>> : etl::integral_constant<size_t, sizeof...(Types)>
|
|
```
|
|
**Description**
|
|
Specialisation of `tuple_size` to allow the use of C++ structured bindings.
|
|
|
|
---
|
|
|
|
```cpp
|
|
template <size_t Index, typename... Types>
|
|
struct tuple_element<Index, etl::tuple<Types...>>
|
|
```
|
|
**Description**
|
|
Specialisation of `tuple_element` to allow the use of C++ structured bindings.
|