Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
decays_to.hpp
Go to the documentation of this file.
1// Copyright 2026, Toyota Motor Corporation
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5///
6/// @file decays_to.hpp
7/// @brief Provides the @c decays_to_v<T, U> trait
8///
9///
10///
11
12#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_TRAITS_DECAYS_TO_HPP_
13#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_TRAITS_DECAYS_TO_HPP_
14
15// IWYU pragma: private, include "arene/base/type_traits.hpp"
16// IWYU pragma: friend "(arene/base(?!/tests)|stdlib/include/stdlib_detail)/.*"
17
18#include "arene/base/stdlib_choice/decay.hpp"
19#include "arene/base/stdlib_choice/is_same.hpp"
20
21namespace arene {
22namespace base {
23
24/// @brief Determine if one type decays to be the same as another type.
25/// @details @c decays_to_v is useful to emulate _deduced-this_ added in C++23
26/// and for other disambiguation needs in overload sets
27///
28/// @code {cpp}
29/// decays_to_v<const int&, int> == true;
30/// decays_to_v<int&&, int> == true;
31/// decays_to_v<int, int> == true;
32/// decays_to_v<int*, int> == false;
33/// decays_to_v<double, int> == false;
34/// @endcode
35///
36/// @tparam T The type to decay and compare to @c U
37/// @tparam U The unqualified type to which the decayed @c T is compared.
38/// @c U is not modified before the comparison.
39template <class T, class U>
40extern constexpr bool decays_to_v = std::is_same<std::decay_t<T>, U>::value;
41
42} // namespace base
43} // namespace arene
44
45#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_TRAITS_DECAYS_TO_HPP_
Definition array_exceptions_disabled.cpp:11
constexpr bool decays_to_v
Determine if one type decays to be the same as another type.
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10