tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
decay.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_TYPE_TRAITS_DECAY_HPP
5#define TETL_TYPE_TRAITS_DECAY_HPP
6
7#include <etl/_type_traits/add_pointer.hpp>
8#include <etl/_type_traits/conditional.hpp>
9#include <etl/_type_traits/is_array.hpp>
10#include <etl/_type_traits/is_function.hpp>
11#include <etl/_type_traits/remove_cv.hpp>
12#include <etl/_type_traits/remove_extent.hpp>
13#include <etl/_type_traits/remove_reference.hpp>
14
15namespace etl {
16
17/// Applies lvalue-to-rvalue, array-to-pointer, and function-to-pointer implicit
18/// conversions to the type T, removes cv-qualifiers, and defines the resulting
19/// type as the member typedef type.
20///
21/// \ingroup type_traits
22template <typename T>
23struct decay {
24private:
25 using U = remove_reference_t<T>;
26
27public:
28 using type = conditional_t<
29 is_array_v<U>,
30 remove_extent_t<U>*,
31 conditional_t<is_function_v<U>, add_pointer_t<U>, remove_cv_t<U>>
32 >;
33};
34
35/// \ingroup type_traits
36template <typename T>
37using decay_t = typename etl::decay<T>::type;
38
39} // namespace etl
40
41#endif // TETL_TYPE_TRAITS_DECAY_HPP
Definition adjacent_find.hpp:9
Applies lvalue-to-rvalue, array-to-pointer, and function-to-pointer implicit conversions to the type ...
Definition decay.hpp:23