tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
make_from_tuple.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2019 Tobias Hienzsch
3
4#ifndef TETL_TUPLE_MAKE_FROM_TUPLE_HPP
5#define TETL_TUPLE_MAKE_FROM_TUPLE_HPP
6
7#include <etl/_tuple/tuple.hpp>
8#include <etl/_tuple/tuple_size.hpp>
9#include <etl/_type_traits/declval.hpp>
10#include <etl/_type_traits/is_constructible.hpp>
11#include <etl/_type_traits/remove_reference.hpp>
12#include <etl/_utility/forward.hpp>
13#include <etl/_utility/index_sequence.hpp>
14
15namespace etl {
16
17template <typename T, typename Tuple>
18[[nodiscard]] constexpr auto make_from_tuple(Tuple&& t) -> T
19{
20 return [&]<etl::size_t... I>(index_sequence<I...> /*i*/) {
21 using etl::get;
22 return T(get<I>(etl::forward<Tuple>(t))...);
23 }(etl::make_index_sequence<etl::tuple_size_v<etl::remove_reference_t<Tuple>>>{});
24}
25
26} // namespace etl
27
28#endif // TETL_TUPLE_MAKE_FROM_TUPLE_HPP
Definition adjacent_find.hpp:9
constexpr auto make_from_tuple(Tuple &&t) -> T
Definition make_from_tuple.hpp:18