tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
add_pointer.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_ADD_POINTER_HPP
5#define TETL_TYPE_TRAITS_ADD_POINTER_HPP
6
7#include <etl/_type_traits/remove_reference.hpp>
8#include <etl/_type_traits/type_identity.hpp>
9
10namespace etl {
11
12namespace detail {
13
14template <typename T>
15auto try_add_pointer(int) -> type_identity<remove_reference_t<T>*>;
16
17template <typename T>
18auto try_add_pointer(...) -> type_identity<T>;
19
20} // namespace detail
21
22/// \brief If T is a reference type, then provides the member typedef type which
23/// is a pointer to the referred type. Otherwise, if T names an object type, a
24/// function type that is not cv- or ref-qualified, or a (possibly cv-qualified)
25/// void type, provides the member typedef type which is the type T*. Otherwise
26/// (if T is a cv- or ref-qualified function type), provides the member typedef
27/// type which is the type T. The behavior of a program that adds
28/// specializations for add_pointer is undefined.
29///
30/// \headerfile etl/type_traits.hpp
31template <typename T>
32struct add_pointer : decltype(detail::try_add_pointer<T>(0)) { };
33
34/// \relates add_pointer
35template <typename T>
36using add_pointer_t = typename add_pointer<T>::type;
37
38} // namespace etl
39
40#endif // TETL_TYPE_TRAITS_ADD_POINTER_HPP
Definition adjacent_find.hpp:9
If T is a reference type, then provides the member typedef type which is a pointer to the referred ty...
Definition add_pointer.hpp:32
Definition type_identity.hpp:11