summaryrefslogtreecommitdiff
path: root/libcxx/include/__memory/pointer_traits.h
diff options
context:
space:
mode:
authorNikolas Klauser <nikolasklauser@berlin.de>2022-07-31 21:54:25 +0200
committerNikolas Klauser <nikolasklauser@berlin.de>2023-01-12 18:28:41 +0100
commit73e8e1ba8daddae1e0f5a013025596e6ff2a0101 (patch)
tree1a672aacd840d66efd65e3f5153cfcd477c80f0e /libcxx/include/__memory/pointer_traits.h
parentedba5d58cd190591516ac8048a1bf4ebd0fb263f (diff)
[libc++][NFC] Qualify declval
While it's not necessary to qualify calls to `declval` it makes error messages very crypric if the declaration isn't reachable anymore For example: ``` /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__chrono/duration.h:53:66: error: no type named 'type' in 'std::common_type<long, long>' typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~ /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__type_traits/common_type.h:107:14: note: in instantiation of template class 'std::common_type<std::chrono::duration<long, std::ratio<3600, 1>>, std::chrono::duration<long, std::ratio<3600, 1>>>' requested here : public common_type<_Tp, _Tp> {}; ^ /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__chrono/duration.h:279:58: note: in instantiation of template class 'std::common_type<std::chrono::duration<long, std::ratio<3600, 1>>>' requested here _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator+() const {return typename common_type<duration>::type(*this);} ^ /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__chrono/duration.h:308:54: note: in instantiation of template class 'std::chrono::duration<long, std::ratio<3600, 1>>' requested here typedef duration< int, ratio_multiply<ratio<24>, hours::period>> days; ^ /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__chrono/duration.h:280:81: error: no type named 'type' in 'std::common_type<std::chrono::duration<long, std::ratio<3600, 1>>>' _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator-() const {return typename common_type<duration>::type(-__rep_);} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~ /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__chrono/duration.h:308:54: note: in instantiation of template class 'std::chrono::duration<long, std::ratio<3600, 1>>' requested here typedef duration< int, ratio_multiply<ratio<24>, hours::period>> days; ^ /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__chrono/duration.h:53:66: error: no type named 'type' in 'std::common_type<int, int>' typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~ /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__type_traits/common_type.h:107:14: note: in instantiation of template class 'std::common_type<std::chrono::duration<int, std::ratio<86400, 1>>, std::chrono::duration<int, std::ratio<86400, 1>>>' requested here : public common_type<_Tp, _Tp> {}; ^ /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__chrono/duration.h:279:58: note: in instantiation of template class 'std::common_type<std::chrono::duration<int, std::ratio<86400, 1>>>' requested here _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator+() const {return typename common_type<duration>::type(*this);} ^ /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__chrono/duration.h:309:55: note: in instantiation of template class 'std::chrono::duration<int, std::ratio<86400, 1>>' requested here typedef duration< int, ratio_multiply<ratio<7>, days::period>> weeks; ^ 19 similar errors omitted ``` changes with qualification added to: ``` While building module 'std' imported from /home/nikolask/llvm-projects/libcxx/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp:13: In file included from <module-includes>:17: In file included from /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/math.h:309: In file included from /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/limits:107: In file included from /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/type_traits:432: In file included from /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__type_traits/common_reference.h:13: /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__type_traits/common_type.h:28:43: error: declaration of 'declval' must be imported from module 'std.utility.__utility.declval' before it is required using __cond_type = decltype(false ? std::declval<_Tp>() : std::declval<_Up>()); ^ /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__utility/declval.h:30:34: note: declaration here is not visible decltype(std::__declval<_Tp>(0)) declval() _NOEXCEPT; ^ /home/nikolask/llvm-projects/libcxx/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp:13:10: fatal error: could not build module 'std' #include <functional> ~~~~~~~~^ 2 errors generated. ``` Reviewed By: ldionne, Mordante, #libc Spies: libcxx-commits Differential Revision: https://reviews.llvm.org/D130854
Diffstat (limited to 'libcxx/include/__memory/pointer_traits.h')
-rw-r--r--libcxx/include/__memory/pointer_traits.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/libcxx/include/__memory/pointer_traits.h b/libcxx/include/__memory/pointer_traits.h
index 67f83f82a01e..c4f20def4540 100644
--- a/libcxx/include/__memory/pointer_traits.h
+++ b/libcxx/include/__memory/pointer_traits.h
@@ -179,7 +179,7 @@ struct _HasToAddress : false_type {};
template <class _Pointer>
struct _HasToAddress<_Pointer,
- decltype((void)pointer_traits<_Pointer>::to_address(declval<const _Pointer&>()))
+ decltype((void)pointer_traits<_Pointer>::to_address(std::declval<const _Pointer&>()))
> : true_type {};
template <class _Pointer, class = void>
@@ -187,7 +187,7 @@ struct _HasArrow : false_type {};
template <class _Pointer>
struct _HasArrow<_Pointer,
- decltype((void)declval<const _Pointer&>().operator->())
+ decltype((void)std::declval<const _Pointer&>().operator->())
> : true_type {};
template <class _Pointer>
@@ -200,7 +200,7 @@ template <class _Pointer, class = __enable_if_t<
_And<is_class<_Pointer>, _IsFancyPointer<_Pointer> >::value
> >
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-typename decay<decltype(__to_address_helper<_Pointer>::__call(declval<const _Pointer&>()))>::type
+typename decay<decltype(__to_address_helper<_Pointer>::__call(std::declval<const _Pointer&>()))>::type
__to_address(const _Pointer& __p) _NOEXCEPT {
return __to_address_helper<_Pointer>::__call(__p);
}
@@ -208,16 +208,16 @@ __to_address(const _Pointer& __p) _NOEXCEPT {
template <class _Pointer, class>
struct __to_address_helper {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- static decltype(_VSTD::__to_address(declval<const _Pointer&>().operator->()))
+ static decltype(_VSTD::__to_address(std::declval<const _Pointer&>().operator->()))
__call(const _Pointer& __p) _NOEXCEPT {
return _VSTD::__to_address(__p.operator->());
}
};
template <class _Pointer>
-struct __to_address_helper<_Pointer, decltype((void)pointer_traits<_Pointer>::to_address(declval<const _Pointer&>()))> {
+struct __to_address_helper<_Pointer, decltype((void)pointer_traits<_Pointer>::to_address(std::declval<const _Pointer&>()))> {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- static decltype(pointer_traits<_Pointer>::to_address(declval<const _Pointer&>()))
+ static decltype(pointer_traits<_Pointer>::to_address(std::declval<const _Pointer&>()))
__call(const _Pointer& __p) _NOEXCEPT {
return pointer_traits<_Pointer>::to_address(__p);
}