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.
20template <typename T>
21struct decay {
22private:
23 using U = remove_reference_t<T>;
24
25public:
26 using type = conditional_t<
27 is_array_v<U>,
28 remove_extent_t<U>*,
29 conditional_t<is_function_v<U>, add_pointer_t<U>, remove_cv_t<U>>
30 >;
31};
32
33template <typename T>
34using decay_t = typename etl::decay<T>::type;
35
36} // namespace etl
37
38#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:21