tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
make_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_TUPLE_HPP
5#define TETL_TUPLE_MAKE_TUPLE_HPP
6
7#include <etl/_functional/reference_wrapper.hpp>
8#include <etl/_tuple/tuple.hpp>
9#include <etl/_type_traits/decay.hpp>
10#include <etl/_utility/forward.hpp>
11
12namespace etl {
13namespace detail {
14template <typename T>
15struct unwrap_refwrapper {
16 using type = T;
17};
18
19template <typename T>
20struct unwrap_refwrapper<reference_wrapper<T>> {
21 using type = T&;
22};
23
24template <typename T>
25using unwrap_decay_t = typename unwrap_refwrapper<decay_t<T>>::type;
26
27} // namespace detail
28
29/// \brief Creates a tuple object, deducing the target type from the types of
30/// arguments.
31template <typename... Args>
32[[nodiscard]] constexpr auto make_tuple(Args&&... args)
33{
34 return etl::tuple<etl::detail::unwrap_decay_t<Args>...>(etl::forward<Args>(args)...);
35}
36} // namespace etl
37
38#endif // TETL_TUPLE_MAKE_TUPLE_HPP
Definition adjacent_find.hpp:9
constexpr auto make_tuple(Args &&... args)
Creates a tuple object, deducing the target type from the types of arguments.
Definition make_tuple.hpp:32
reference_wrapper is a class template that wraps a reference in a copyable, assignable object....
Definition reference_wrapper.hpp:41
Definition tuple.hpp:114