[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
This commit is contained in:
parent
edba5d58cd
commit
73e8e1ba8d
@ -49,8 +49,8 @@ struct __debug_less
|
||||
template <class _LHS, class _RHS>
|
||||
_LIBCPP_CONSTEXPR_SINCE_CXX14
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
decltype((void)declval<_Compare&>()(
|
||||
declval<_LHS &>(), declval<_RHS &>()))
|
||||
decltype((void)std::declval<_Compare&>()(
|
||||
std::declval<_LHS &>(), std::declval<_RHS &>()))
|
||||
__do_compare_assert(int, _LHS & __l, _RHS & __r) {
|
||||
_LIBCPP_DEBUG_ASSERT(!__comp_(__l, __r),
|
||||
"Comparator does not induce a strict weak ordering");
|
||||
|
||||
@ -23,7 +23,7 @@ template <class _ForwardIterator1, class _ForwardIterator2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void iter_swap(_ForwardIterator1 __a,
|
||||
_ForwardIterator2 __b)
|
||||
// _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
|
||||
_NOEXCEPT_(_NOEXCEPT_(swap(*declval<_ForwardIterator1>(), *declval<_ForwardIterator2>()))) {
|
||||
_NOEXCEPT_(_NOEXCEPT_(swap(*std::declval<_ForwardIterator1>(), *std::declval<_ForwardIterator2>()))) {
|
||||
swap(*__a, *__b);
|
||||
}
|
||||
|
||||
|
||||
@ -26,9 +26,9 @@ struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result { };
|
||||
|
||||
template<class _Tp, class _Up>
|
||||
struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result<_Tp, _Up, decltype(
|
||||
declval<__make_const_lvalue_ref<_Tp>>() <=> declval<__make_const_lvalue_ref<_Up>>(), void()
|
||||
std::declval<__make_const_lvalue_ref<_Tp>>() <=> std::declval<__make_const_lvalue_ref<_Up>>(), void()
|
||||
)> {
|
||||
using type = decltype(declval<__make_const_lvalue_ref<_Tp>>() <=> declval<__make_const_lvalue_ref<_Up>>());
|
||||
using type = decltype(std::declval<__make_const_lvalue_ref<_Tp>>() <=> std::declval<__make_const_lvalue_ref<_Up>>());
|
||||
};
|
||||
|
||||
template<class _Tp, class _Up = _Tp>
|
||||
|
||||
@ -42,7 +42,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way =
|
||||
};
|
||||
|
||||
template <class _Tp, class _Up = _Tp>
|
||||
using __synth_three_way_result = decltype(std::__synth_three_way(declval<_Tp&>(), declval<_Up&>()));
|
||||
using __synth_three_way_result = decltype(std::__synth_three_way(std::declval<_Tp&>(), std::declval<_Up&>()));
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 17
|
||||
|
||||
|
||||
@ -31,8 +31,8 @@ template<class _Tp, class _Up>
|
||||
concept common_with =
|
||||
same_as<common_type_t<_Tp, _Up>, common_type_t<_Up, _Tp>> &&
|
||||
requires {
|
||||
static_cast<common_type_t<_Tp, _Up>>(declval<_Tp>());
|
||||
static_cast<common_type_t<_Tp, _Up>>(declval<_Up>());
|
||||
static_cast<common_type_t<_Tp, _Up>>(std::declval<_Tp>());
|
||||
static_cast<common_type_t<_Tp, _Up>>(std::declval<_Up>());
|
||||
} &&
|
||||
common_reference_with<
|
||||
add_lvalue_reference_t<const _Tp>,
|
||||
|
||||
@ -27,7 +27,7 @@ template<class _From, class _To>
|
||||
concept convertible_to =
|
||||
is_convertible_v<_From, _To> &&
|
||||
requires {
|
||||
static_cast<_To>(declval<_From>());
|
||||
static_cast<_To>(std::declval<_From>());
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 17
|
||||
|
||||
@ -161,7 +161,7 @@ public:
|
||||
using _Dp = remove_cvref_t<_Tp>;
|
||||
using _Formatter = typename _Context::template formatter_type<_Dp>;
|
||||
constexpr bool __const_formattable =
|
||||
requires { _Formatter().format(declval<const _Dp&>(), declval<_Context&>()); };
|
||||
requires { _Formatter().format(std::declval<const _Dp&>(), std::declval<_Context&>()); };
|
||||
using _Qp = conditional_t<__const_formattable, const _Dp, _Dp>;
|
||||
|
||||
static_assert(__const_formattable || !is_const_v<remove_reference_t<_Tp>>, "Mandated by [format.arg]/18");
|
||||
|
||||
@ -398,7 +398,7 @@ template <class _Ret, class _Fp, class ..._Args>
|
||||
struct __invokable_r
|
||||
{
|
||||
template <class _XFp, class ..._XArgs>
|
||||
static decltype(std::__invoke(declval<_XFp>(), declval<_XArgs>()...)) __try_call(int);
|
||||
static decltype(std::__invoke(std::declval<_XFp>(), std::declval<_XArgs>()...)) __try_call(int);
|
||||
template <class _XFp, class ..._XArgs>
|
||||
static __nat __try_call(...);
|
||||
|
||||
@ -432,7 +432,7 @@ struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
|
||||
static const bool value = false;
|
||||
#else
|
||||
static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
|
||||
_VSTD::__invoke(declval<_Fp>(), declval<_Args>()...)));
|
||||
_VSTD::__invoke(std::declval<_Fp>(), std::declval<_Args>()...)));
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -443,7 +443,7 @@ struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
|
||||
static const bool value = false;
|
||||
#else
|
||||
static const bool value = noexcept(
|
||||
_VSTD::__invoke(declval<_Fp>(), declval<_Args>()...));
|
||||
_VSTD::__invoke(std::declval<_Fp>(), std::declval<_Args>()...));
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@ -38,9 +38,9 @@ private:
|
||||
static void __fun(_Tp&&) = delete;
|
||||
|
||||
public:
|
||||
template <class _Up, class = __enable_if_t<!__is_same_uncvref<_Up, reference_wrapper>::value, decltype(__fun(declval<_Up>())) > >
|
||||
template <class _Up, class = __enable_if_t<!__is_same_uncvref<_Up, reference_wrapper>::value, decltype(__fun(std::declval<_Up>())) > >
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
|
||||
reference_wrapper(_Up&& __u) _NOEXCEPT_(noexcept(__fun(declval<_Up>()))) {
|
||||
reference_wrapper(_Up&& __u) _NOEXCEPT_(noexcept(__fun(std::declval<_Up>()))) {
|
||||
type& __f = static_cast<_Up&&>(__u);
|
||||
__f_ = _VSTD::addressof(__f);
|
||||
}
|
||||
|
||||
@ -286,7 +286,7 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>
|
||||
template <class _Tp, class ..._Args>
|
||||
struct __invoke_return
|
||||
{
|
||||
typedef decltype(_VSTD::__invoke(declval<_Tp>(), declval<_Args>()...)) type;
|
||||
typedef decltype(_VSTD::__invoke(std::declval<_Tp>(), std::declval<_Args>()...)) type;
|
||||
};
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
@ -58,7 +58,7 @@ void __advance(_RandIter& __i, typename iterator_traits<_RandIter>::difference_t
|
||||
|
||||
template <
|
||||
class _InputIter, class _Distance,
|
||||
class _IntegralDistance = decltype(_VSTD::__convert_to_integral(declval<_Distance>())),
|
||||
class _IntegralDistance = decltype(_VSTD::__convert_to_integral(std::declval<_Distance>())),
|
||||
class = __enable_if_t<is_integral<_IntegralDistance>::value> >
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
|
||||
void advance(_InputIter& __i, _Distance __orig_n) {
|
||||
|
||||
@ -217,7 +217,7 @@ public:
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI friend constexpr iter_rvalue_reference_t<_Iter> iter_move(const common_iterator& __i)
|
||||
noexcept(noexcept(ranges::iter_move(declval<const _Iter&>())))
|
||||
noexcept(noexcept(ranges::iter_move(std::declval<const _Iter&>())))
|
||||
requires input_iterator<_Iter>
|
||||
{
|
||||
_LIBCPP_ASSERT(std::holds_alternative<_Iter>(__i.__hold_), "Attempted to iter_move a non-dereferenceable common_iterator");
|
||||
@ -226,7 +226,7 @@ public:
|
||||
|
||||
template<indirectly_swappable<_Iter> _I2, class _S2>
|
||||
_LIBCPP_HIDE_FROM_ABI friend constexpr void iter_swap(const common_iterator& __x, const common_iterator<_I2, _S2>& __y)
|
||||
noexcept(noexcept(ranges::iter_swap(declval<const _Iter&>(), declval<const _I2&>())))
|
||||
noexcept(noexcept(ranges::iter_swap(std::declval<const _Iter&>(), std::declval<const _I2&>())))
|
||||
{
|
||||
_LIBCPP_ASSERT(std::holds_alternative<_Iter>(__x.__hold_), "Attempted to iter_swap a non-dereferenceable common_iterator");
|
||||
_LIBCPP_ASSERT(std::holds_alternative<_I2>(__y.__hold_), "Attempted to iter_swap a non-dereferenceable common_iterator");
|
||||
@ -257,7 +257,7 @@ struct __arrow_type_or_void {
|
||||
template<class _Iter, class _Sent>
|
||||
requires __common_iter_has_ptr_op<_Iter, _Sent>
|
||||
struct __arrow_type_or_void<_Iter, _Sent> {
|
||||
using type = decltype(declval<const common_iterator<_Iter, _Sent>&>().operator->());
|
||||
using type = decltype(std::declval<const common_iterator<_Iter, _Sent>&>().operator->());
|
||||
};
|
||||
|
||||
template<input_iterator _Iter, class _Sent>
|
||||
|
||||
@ -57,7 +57,7 @@ concept __has_integral_minus =
|
||||
template<__has_integral_minus _Tp>
|
||||
requires (!__has_member_difference_type<_Tp>)
|
||||
struct incrementable_traits<_Tp> {
|
||||
using difference_type = make_signed_t<decltype(declval<_Tp>() - declval<_Tp>())>;
|
||||
using difference_type = make_signed_t<decltype(std::declval<_Tp>() - std::declval<_Tp>())>;
|
||||
};
|
||||
|
||||
template <class>
|
||||
|
||||
@ -95,7 +95,7 @@ inline namespace __cpo {
|
||||
|
||||
template<__dereferenceable _Tp>
|
||||
requires requires(_Tp& __t) { { ranges::iter_move(__t) } -> __can_reference; }
|
||||
using iter_rvalue_reference_t = decltype(ranges::iter_move(declval<_Tp&>()));
|
||||
using iter_rvalue_reference_t = decltype(ranges::iter_move(std::declval<_Tp&>()));
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 17
|
||||
|
||||
|
||||
@ -82,7 +82,7 @@ namespace __iter_swap {
|
||||
constexpr void operator()(_T1&& __x, _T2&& __y) const
|
||||
noexcept(noexcept(iter_value_t<_T2>(ranges::iter_move(__y))) &&
|
||||
noexcept(*__y = ranges::iter_move(__x)) &&
|
||||
noexcept(*_VSTD::forward<_T1>(__x) = declval<iter_value_t<_T2>>()))
|
||||
noexcept(*_VSTD::forward<_T1>(__x) = std::declval<iter_value_t<_T2>>()))
|
||||
{
|
||||
iter_value_t<_T2> __old(ranges::iter_move(__y));
|
||||
*__y = ranges::iter_move(__x);
|
||||
|
||||
@ -60,7 +60,7 @@ concept __dereferenceable = requires(_Tp& __t) {
|
||||
|
||||
// [iterator.traits]
|
||||
template<__dereferenceable _Tp>
|
||||
using iter_reference_t = decltype(*declval<_Tp&>());
|
||||
using iter_reference_t = decltype(*std::declval<_Tp&>());
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 17
|
||||
|
||||
@ -273,7 +273,7 @@ struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> { using type = typ
|
||||
template<class _Ip>
|
||||
requires requires(_Ip& __i) { __i.operator->(); } && (!__has_member_pointer<_Ip>)
|
||||
struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> {
|
||||
using type = decltype(declval<_Ip&>().operator->());
|
||||
using type = decltype(std::declval<_Ip&>().operator->());
|
||||
};
|
||||
|
||||
// Otherwise, `reference` names `iter-reference-t<I>`.
|
||||
|
||||
@ -53,7 +53,7 @@ struct __move_iter_category_base<_Iter> {
|
||||
|
||||
template<class _Iter, class _Sent>
|
||||
concept __move_iter_comparable = requires {
|
||||
{ declval<const _Iter&>() == declval<_Sent>() } -> convertible_to<bool>;
|
||||
{ std::declval<const _Iter&>() == std::declval<_Sent>() } -> convertible_to<bool>;
|
||||
};
|
||||
#endif // _LIBCPP_STD_VER > 17
|
||||
|
||||
|
||||
@ -184,7 +184,7 @@ public:
|
||||
_LIBCPP_HIDE_FROM_ABI friend constexpr
|
||||
iter_rvalue_reference_t<_Iter> iter_move(const reverse_iterator& __i)
|
||||
noexcept(is_nothrow_copy_constructible_v<_Iter> &&
|
||||
noexcept(ranges::iter_move(--declval<_Iter&>()))) {
|
||||
noexcept(ranges::iter_move(--std::declval<_Iter&>()))) {
|
||||
auto __tmp = __i.base();
|
||||
return ranges::iter_move(--__tmp);
|
||||
}
|
||||
@ -194,7 +194,7 @@ public:
|
||||
void iter_swap(const reverse_iterator& __x, const reverse_iterator<_Iter2>& __y)
|
||||
noexcept(is_nothrow_copy_constructible_v<_Iter> &&
|
||||
is_nothrow_copy_constructible_v<_Iter2> &&
|
||||
noexcept(ranges::iter_swap(--declval<_Iter&>(), --declval<_Iter2&>()))) {
|
||||
noexcept(ranges::iter_swap(--std::declval<_Iter&>(), --std::declval<_Iter2&>()))) {
|
||||
auto __xtmp = __x.base();
|
||||
auto __ytmp = __y.base();
|
||||
ranges::iter_swap(--__xtmp, --__ytmp);
|
||||
@ -401,7 +401,7 @@ public:
|
||||
_LIBCPP_HIDE_FROM_ABI friend constexpr
|
||||
iter_rvalue_reference_t<_Iter> iter_move(const __unconstrained_reverse_iterator& __i)
|
||||
noexcept(is_nothrow_copy_constructible_v<_Iter> &&
|
||||
noexcept(ranges::iter_move(--declval<_Iter&>()))) {
|
||||
noexcept(ranges::iter_move(--std::declval<_Iter&>()))) {
|
||||
auto __tmp = __i.base();
|
||||
return ranges::iter_move(--__tmp);
|
||||
}
|
||||
|
||||
@ -187,7 +187,7 @@ struct __has_allocate_hint : false_type { };
|
||||
|
||||
template <class _Alloc, class _SizeType, class _ConstVoidPtr>
|
||||
struct __has_allocate_hint<_Alloc, _SizeType, _ConstVoidPtr, decltype(
|
||||
(void)declval<_Alloc>().allocate(declval<_SizeType>(), declval<_ConstVoidPtr>())
|
||||
(void)std::declval<_Alloc>().allocate(std::declval<_SizeType>(), std::declval<_ConstVoidPtr>())
|
||||
)> : true_type { };
|
||||
|
||||
// __has_construct
|
||||
@ -196,7 +196,7 @@ struct __has_construct_impl : false_type { };
|
||||
|
||||
template <class _Alloc, class ..._Args>
|
||||
struct __has_construct_impl<decltype(
|
||||
(void)declval<_Alloc>().construct(declval<_Args>()...)
|
||||
(void)std::declval<_Alloc>().construct(std::declval<_Args>()...)
|
||||
), _Alloc, _Args...> : true_type { };
|
||||
|
||||
template <class _Alloc, class ..._Args>
|
||||
@ -208,7 +208,7 @@ struct __has_destroy : false_type { };
|
||||
|
||||
template <class _Alloc, class _Pointer>
|
||||
struct __has_destroy<_Alloc, _Pointer, decltype(
|
||||
(void)declval<_Alloc>().destroy(declval<_Pointer>())
|
||||
(void)std::declval<_Alloc>().destroy(std::declval<_Pointer>())
|
||||
)> : true_type { };
|
||||
|
||||
// __has_max_size
|
||||
@ -217,7 +217,7 @@ struct __has_max_size : false_type { };
|
||||
|
||||
template <class _Alloc>
|
||||
struct __has_max_size<_Alloc, decltype(
|
||||
(void)declval<_Alloc&>().max_size()
|
||||
(void)std::declval<_Alloc&>().max_size()
|
||||
)> : true_type { };
|
||||
|
||||
// __has_select_on_container_copy_construction
|
||||
@ -226,7 +226,7 @@ struct __has_select_on_container_copy_construction : false_type { };
|
||||
|
||||
template <class _Alloc>
|
||||
struct __has_select_on_container_copy_construction<_Alloc, decltype(
|
||||
(void)declval<_Alloc>().select_on_container_copy_construction()
|
||||
(void)std::declval<_Alloc>().select_on_container_copy_construction()
|
||||
)> : true_type { };
|
||||
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_POP
|
||||
|
||||
@ -32,7 +32,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER > 17
|
||||
|
||||
template <class _Tp, class... _Args, class = decltype(::new(declval<void*>()) _Tp(declval<_Args>()...))>
|
||||
template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))>
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr _Tp* construct_at(_Tp* __location, _Args&&... __args) {
|
||||
_LIBCPP_ASSERT(__location != nullptr, "null pointer given to construct_at");
|
||||
return ::new (_VSTD::__voidify(*__location)) _Tp(_VSTD::forward<_Args>(__args)...);
|
||||
@ -40,7 +40,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp* construct_at(_Tp* __location, _Args&&... __
|
||||
|
||||
#endif
|
||||
|
||||
template <class _Tp, class... _Args, class = decltype(::new(declval<void*>()) _Tp(declval<_Args>()...))>
|
||||
template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))>
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __construct_at(_Tp* __location, _Args&&... __args) {
|
||||
#if _LIBCPP_STD_VER > 17
|
||||
return std::construct_at(__location, std::forward<_Args>(__args)...);
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ namespace __construct_at {
|
||||
|
||||
struct __fn {
|
||||
template<class _Tp, class... _Args, class = decltype(
|
||||
::new (declval<void*>()) _Tp(declval<_Args>()...)
|
||||
::new (std::declval<void*>()) _Tp(std::declval<_Args>()...)
|
||||
)>
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr _Tp* operator()(_Tp* __location, _Args&& ...__args) const {
|
||||
|
||||
@ -366,15 +366,15 @@ struct __compatible_with
|
||||
template <class _Ptr, class = void>
|
||||
struct __is_deletable : false_type { };
|
||||
template <class _Ptr>
|
||||
struct __is_deletable<_Ptr, decltype(delete declval<_Ptr>())> : true_type { };
|
||||
struct __is_deletable<_Ptr, decltype(delete std::declval<_Ptr>())> : true_type { };
|
||||
|
||||
template <class _Ptr, class = void>
|
||||
struct __is_array_deletable : false_type { };
|
||||
template <class _Ptr>
|
||||
struct __is_array_deletable<_Ptr, decltype(delete[] declval<_Ptr>())> : true_type { };
|
||||
struct __is_array_deletable<_Ptr, decltype(delete[] std::declval<_Ptr>())> : true_type { };
|
||||
|
||||
template <class _Dp, class _Pt,
|
||||
class = decltype(declval<_Dp>()(declval<_Pt>()))>
|
||||
class = decltype(std::declval<_Dp>()(std::declval<_Pt>()))>
|
||||
static true_type __well_formed_deleter_test(int);
|
||||
|
||||
template <class, class>
|
||||
|
||||
@ -53,7 +53,7 @@ template<> struct __libcpp_random_is_valid_inttype<__uint128_t> : true_type {};
|
||||
template<class, class = void> struct __libcpp_random_is_valid_urng : false_type {};
|
||||
template<class _Gp> struct __libcpp_random_is_valid_urng<_Gp, __enable_if_t<
|
||||
is_unsigned<typename _Gp::result_type>::value &&
|
||||
_IsSame<decltype(declval<_Gp&>()()), typename _Gp::result_type>::value
|
||||
_IsSame<decltype(std::declval<_Gp&>()()), typename _Gp::result_type>::value
|
||||
> > : true_type {};
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
@ -105,7 +105,7 @@ inline namespace __cpo {
|
||||
|
||||
namespace ranges {
|
||||
template <class _Tp>
|
||||
using iterator_t = decltype(ranges::begin(declval<_Tp&>()));
|
||||
using iterator_t = decltype(ranges::begin(std::declval<_Tp&>()));
|
||||
} // namespace ranges
|
||||
|
||||
// [range.access.end]
|
||||
|
||||
@ -73,7 +73,7 @@ inline namespace __cpo {
|
||||
} // namespace __cpo
|
||||
|
||||
template<ranges::viewable_range _Range>
|
||||
using all_t = decltype(views::all(declval<_Range>()));
|
||||
using all_t = decltype(views::all(std::declval<_Range>()));
|
||||
|
||||
} // namespace ranges::views
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@ namespace ranges {
|
||||
// `iterator_t` defined in <__ranges/access.h>
|
||||
|
||||
template <range _Rp>
|
||||
using sentinel_t = decltype(ranges::end(declval<_Rp&>()));
|
||||
using sentinel_t = decltype(ranges::end(std::declval<_Rp&>()));
|
||||
|
||||
template <range _Rp>
|
||||
using range_difference_t = iter_difference_t<iterator_t<_Rp>>;
|
||||
@ -78,7 +78,7 @@ namespace ranges {
|
||||
concept sized_range = range<_Tp> && requires(_Tp& __t) { ranges::size(__t); };
|
||||
|
||||
template<sized_range _Rp>
|
||||
using range_size_t = decltype(ranges::size(declval<_Rp&>()));
|
||||
using range_size_t = decltype(ranges::size(std::declval<_Rp&>()));
|
||||
|
||||
// `disable_sized_range` defined in `<__ranges/size.h>`
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ namespace ranges {
|
||||
public:
|
||||
template<class _Tp>
|
||||
requires __different_from<_Tp, ref_view> &&
|
||||
convertible_to<_Tp, _Range&> && requires { __fun(declval<_Tp>()); }
|
||||
convertible_to<_Tp, _Range&> && requires { __fun(std::declval<_Tp>()); }
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr ref_view(_Tp&& __t)
|
||||
: __range_(std::addressof(static_cast<_Range&>(std::forward<_Tp>(__t))))
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
#include <__type_traits/make_unsigned.h>
|
||||
#include <__type_traits/remove_cvref.h>
|
||||
#include <__utility/auto_cast.h>
|
||||
#include <__utility/declval.h>
|
||||
#include <cstddef>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
@ -70,7 +71,7 @@ concept __difference =
|
||||
__class_or_enum<remove_cvref_t<_Tp>> &&
|
||||
requires(_Tp&& __t) {
|
||||
{ ranges::begin(__t) } -> forward_iterator;
|
||||
{ ranges::end(__t) } -> sized_sentinel_for<decltype(ranges::begin(declval<_Tp>()))>;
|
||||
{ ranges::end(__t) } -> sized_sentinel_for<decltype(ranges::begin(std::declval<_Tp>()))>;
|
||||
};
|
||||
|
||||
struct __fn {
|
||||
|
||||
@ -403,15 +403,15 @@ public:
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr auto iter_move(const __iterator& __i) noexcept(
|
||||
(noexcept(ranges::iter_move(declval<const iterator_t<__maybe_const<_Const, _Views>>&>())) && ...) &&
|
||||
(noexcept(ranges::iter_move(std::declval<const iterator_t<__maybe_const<_Const, _Views>>&>())) && ...) &&
|
||||
(is_nothrow_move_constructible_v<range_rvalue_reference_t<__maybe_const<_Const, _Views>>> && ...)) {
|
||||
return ranges::__tuple_transform(ranges::iter_move, __i.__current_);
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr void iter_swap(const __iterator& __l, const __iterator& __r) noexcept(
|
||||
(noexcept(ranges::iter_swap(declval<const iterator_t<__maybe_const<_Const, _Views>>&>(),
|
||||
declval<const iterator_t<__maybe_const<_Const, _Views>>&>())) &&
|
||||
(noexcept(ranges::iter_swap(std::declval<const iterator_t<__maybe_const<_Const, _Views>>&>(),
|
||||
std::declval<const iterator_t<__maybe_const<_Const, _Views>>&>())) &&
|
||||
...))
|
||||
requires(indirectly_swappable<iterator_t<__maybe_const<_Const, _Views>>> && ...) {
|
||||
ranges::__tuple_zip_for_each(ranges::iter_swap, __l.__current_, __r.__current_);
|
||||
|
||||
@ -31,7 +31,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
|
||||
// Let COND_RES(X, Y) be:
|
||||
template <class _Xp, class _Yp>
|
||||
using __cond_res =
|
||||
decltype(false ? declval<_Xp(&)()>()() : declval<_Yp(&)()>()());
|
||||
decltype(false ? std::declval<_Xp(&)()>()() : std::declval<_Yp(&)()>()());
|
||||
|
||||
// Let `XREF(A)` denote a unary alias template `T` such that `T<U>` denotes the same type as `U`
|
||||
// with the addition of `A`'s cv and reference qualifiers, for a non-reference cv-unqualified type
|
||||
|
||||
@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
|
||||
#if _LIBCPP_STD_VER > 17
|
||||
// Let COND_RES(X, Y) be:
|
||||
template <class _Tp, class _Up>
|
||||
using __cond_type = decltype(false ? declval<_Tp>() : declval<_Up>());
|
||||
using __cond_type = decltype(false ? std::declval<_Tp>() : std::declval<_Up>());
|
||||
|
||||
template <class _Tp, class _Up, class = void>
|
||||
struct __common_type3 {};
|
||||
@ -47,10 +47,10 @@ struct __common_type2_imp {};
|
||||
|
||||
// sub-bullet 3 - "if decay_t<decltype(false ? declval<D1>() : declval<D2>())> ..."
|
||||
template <class _Tp, class _Up>
|
||||
struct __common_type2_imp<_Tp, _Up, __void_t<decltype(true ? declval<_Tp>() : declval<_Up>())> >
|
||||
struct __common_type2_imp<_Tp, _Up, __void_t<decltype(true ? std::declval<_Tp>() : std::declval<_Up>())> >
|
||||
{
|
||||
typedef _LIBCPP_NODEBUG typename decay<decltype(
|
||||
true ? declval<_Tp>() : declval<_Up>()
|
||||
true ? std::declval<_Tp>() : std::declval<_Up>()
|
||||
)>::type type;
|
||||
};
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ struct __is_allocator : false_type {};
|
||||
template<typename _Alloc>
|
||||
struct __is_allocator<_Alloc,
|
||||
__void_t<typename _Alloc::value_type>,
|
||||
__void_t<decltype(declval<_Alloc&>().allocate(size_t(0)))>
|
||||
__void_t<decltype(std::declval<_Alloc&>().allocate(size_t(0)))>
|
||||
>
|
||||
: true_type {};
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ struct __is_convertible_test : public false_type {};
|
||||
|
||||
template <class _From, class _To>
|
||||
struct __is_convertible_test<_From, _To,
|
||||
decltype(__is_convertible_imp::__test_convert<_To>(declval<_From>()))> : public true_type
|
||||
decltype(__is_convertible_imp::__test_convert<_To>(std::declval<_From>()))> : public true_type
|
||||
{};
|
||||
|
||||
template <class _Tp, bool _IsArray = is_array<_Tp>::value,
|
||||
|
||||
@ -48,7 +48,7 @@ template <typename _Tp>
|
||||
struct __is_destructor_wellformed {
|
||||
template <typename _Tp1>
|
||||
static true_type __test (
|
||||
typename __is_destructible_apply<decltype(declval<_Tp1&>().~_Tp1())>::type
|
||||
typename __is_destructible_apply<decltype(std::declval<_Tp1&>().~_Tp1())>::type
|
||||
);
|
||||
|
||||
template <typename _Tp1>
|
||||
|
||||
@ -34,7 +34,7 @@ template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_cons
|
||||
|
||||
template <class _Tp, class... _Args>
|
||||
struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
|
||||
: public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
|
||||
: public integral_constant<bool, noexcept(_Tp(std::declval<_Args>()...))>
|
||||
{
|
||||
};
|
||||
|
||||
@ -43,7 +43,7 @@ void __implicit_conversion_to(_Tp) noexcept { }
|
||||
|
||||
template <class _Tp, class _Arg>
|
||||
struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
|
||||
: public integral_constant<bool, noexcept(_VSTD::__implicit_conversion_to<_Tp>(declval<_Arg>()))>
|
||||
: public integral_constant<bool, noexcept(_VSTD::__implicit_conversion_to<_Tp>(std::declval<_Arg>()))>
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ template <typename _Tp>
|
||||
static void __test_noexcept(_Tp) noexcept;
|
||||
|
||||
template<typename _Fm, typename _To>
|
||||
static bool_constant<noexcept(_VSTD::__test_noexcept<_To>(declval<_Fm>()))>
|
||||
static bool_constant<noexcept(_VSTD::__test_noexcept<_To>(std::declval<_Fm>()))>
|
||||
__is_nothrow_convertible_test();
|
||||
|
||||
template <typename _Fm, typename _To>
|
||||
|
||||
@ -36,7 +36,7 @@ struct __libcpp_is_nothrow_destructible<false, _Tp>
|
||||
|
||||
template <class _Tp>
|
||||
struct __libcpp_is_nothrow_destructible<true, _Tp>
|
||||
: public integral_constant<bool, noexcept(declval<_Tp>().~_Tp()) >
|
||||
: public integral_constant<bool, noexcept(std::declval<_Tp>().~_Tp()) >
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ template <class _Tp, class _Up = _Tp,
|
||||
struct __swappable_with
|
||||
{
|
||||
template <class _LHS, class _RHS>
|
||||
static decltype(swap(declval<_LHS>(), declval<_RHS>()))
|
||||
static decltype(swap(std::declval<_LHS>(), std::declval<_RHS>()))
|
||||
__test_swap(int);
|
||||
template <class, class>
|
||||
static __nat __test_swap(long);
|
||||
@ -84,8 +84,8 @@ template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _U
|
||||
struct __nothrow_swappable_with {
|
||||
static const bool value =
|
||||
#ifndef _LIBCPP_HAS_NO_NOEXCEPT
|
||||
noexcept(swap(declval<_Tp>(), declval<_Up>()))
|
||||
&& noexcept(swap(declval<_Up>(), declval<_Tp>()));
|
||||
noexcept(swap(std::declval<_Tp>(), std::declval<_Up>()))
|
||||
&& noexcept(swap(std::declval<_Up>(), std::declval<_Tp>()));
|
||||
#else
|
||||
false;
|
||||
#endif
|
||||
|
||||
@ -40,7 +40,7 @@ struct __numeric_type
|
||||
static double __test(double);
|
||||
static long double __test(long double);
|
||||
|
||||
typedef decltype(__test(declval<_Tp>())) type;
|
||||
typedef decltype(__test(std::declval<_Tp>())) type;
|
||||
static const bool value = _IsNotSame<type, void>::value;
|
||||
};
|
||||
|
||||
|
||||
@ -139,7 +139,7 @@ template <class _Tp>
|
||||
class propagate_const
|
||||
{
|
||||
public:
|
||||
typedef remove_reference_t<decltype(*declval<_Tp&>())> element_type;
|
||||
typedef remove_reference_t<decltype(*std::declval<_Tp&>())> element_type;
|
||||
|
||||
static_assert(!is_array<_Tp>::value,
|
||||
"Instantiation of propagate_const with an array type is ill-formed.");
|
||||
|
||||
@ -1375,7 +1375,7 @@ struct __is_istreamable : false_type { };
|
||||
|
||||
template <class _Stream, class _Tp>
|
||||
struct __is_istreamable<_Stream, _Tp, decltype(
|
||||
declval<_Stream>() >> declval<_Tp>(), void()
|
||||
std::declval<_Stream>() >> std::declval<_Tp>(), void()
|
||||
)> : true_type { };
|
||||
|
||||
template <class _Stream, class _Tp, class = typename enable_if<
|
||||
|
||||
@ -1185,8 +1185,8 @@ template<class _Tp>
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr
|
||||
enable_if_t<
|
||||
is_convertible_v<decltype(declval<const _Tp&>() ==
|
||||
declval<const _Up&>()), bool>,
|
||||
is_convertible_v<decltype(std::declval<const _Tp&>() ==
|
||||
std::declval<const _Up&>()), bool>,
|
||||
bool
|
||||
>
|
||||
operator==(const optional<_Tp>& __x, const optional<_Up>& __y)
|
||||
@ -1201,8 +1201,8 @@ operator==(const optional<_Tp>& __x, const optional<_Up>& __y)
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr
|
||||
enable_if_t<
|
||||
is_convertible_v<decltype(declval<const _Tp&>() !=
|
||||
declval<const _Up&>()), bool>,
|
||||
is_convertible_v<decltype(std::declval<const _Tp&>() !=
|
||||
std::declval<const _Up&>()), bool>,
|
||||
bool
|
||||
>
|
||||
operator!=(const optional<_Tp>& __x, const optional<_Up>& __y)
|
||||
@ -1217,8 +1217,8 @@ operator!=(const optional<_Tp>& __x, const optional<_Up>& __y)
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr
|
||||
enable_if_t<
|
||||
is_convertible_v<decltype(declval<const _Tp&>() <
|
||||
declval<const _Up&>()), bool>,
|
||||
is_convertible_v<decltype(std::declval<const _Tp&>() <
|
||||
std::declval<const _Up&>()), bool>,
|
||||
bool
|
||||
>
|
||||
operator<(const optional<_Tp>& __x, const optional<_Up>& __y)
|
||||
@ -1233,8 +1233,8 @@ operator<(const optional<_Tp>& __x, const optional<_Up>& __y)
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr
|
||||
enable_if_t<
|
||||
is_convertible_v<decltype(declval<const _Tp&>() >
|
||||
declval<const _Up&>()), bool>,
|
||||
is_convertible_v<decltype(std::declval<const _Tp&>() >
|
||||
std::declval<const _Up&>()), bool>,
|
||||
bool
|
||||
>
|
||||
operator>(const optional<_Tp>& __x, const optional<_Up>& __y)
|
||||
@ -1249,8 +1249,8 @@ operator>(const optional<_Tp>& __x, const optional<_Up>& __y)
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr
|
||||
enable_if_t<
|
||||
is_convertible_v<decltype(declval<const _Tp&>() <=
|
||||
declval<const _Up&>()), bool>,
|
||||
is_convertible_v<decltype(std::declval<const _Tp&>() <=
|
||||
std::declval<const _Up&>()), bool>,
|
||||
bool
|
||||
>
|
||||
operator<=(const optional<_Tp>& __x, const optional<_Up>& __y)
|
||||
@ -1265,8 +1265,8 @@ operator<=(const optional<_Tp>& __x, const optional<_Up>& __y)
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr
|
||||
enable_if_t<
|
||||
is_convertible_v<decltype(declval<const _Tp&>() >=
|
||||
declval<const _Up&>()), bool>,
|
||||
is_convertible_v<decltype(std::declval<const _Tp&>() >=
|
||||
std::declval<const _Up&>()), bool>,
|
||||
bool
|
||||
>
|
||||
operator>=(const optional<_Tp>& __x, const optional<_Up>& __y)
|
||||
@ -1379,8 +1379,8 @@ operator>=(nullopt_t, const optional<_Tp>& __x) noexcept
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr
|
||||
enable_if_t<
|
||||
is_convertible_v<decltype(declval<const _Tp&>() ==
|
||||
declval<const _Up&>()), bool>,
|
||||
is_convertible_v<decltype(std::declval<const _Tp&>() ==
|
||||
std::declval<const _Up&>()), bool>,
|
||||
bool
|
||||
>
|
||||
operator==(const optional<_Tp>& __x, const _Up& __v)
|
||||
@ -1391,8 +1391,8 @@ operator==(const optional<_Tp>& __x, const _Up& __v)
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr
|
||||
enable_if_t<
|
||||
is_convertible_v<decltype(declval<const _Tp&>() ==
|
||||
declval<const _Up&>()), bool>,
|
||||
is_convertible_v<decltype(std::declval<const _Tp&>() ==
|
||||
std::declval<const _Up&>()), bool>,
|
||||
bool
|
||||
>
|
||||
operator==(const _Tp& __v, const optional<_Up>& __x)
|
||||
@ -1403,8 +1403,8 @@ operator==(const _Tp& __v, const optional<_Up>& __x)
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr
|
||||
enable_if_t<
|
||||
is_convertible_v<decltype(declval<const _Tp&>() !=
|
||||
declval<const _Up&>()), bool>,
|
||||
is_convertible_v<decltype(std::declval<const _Tp&>() !=
|
||||
std::declval<const _Up&>()), bool>,
|
||||
bool
|
||||
>
|
||||
operator!=(const optional<_Tp>& __x, const _Up& __v)
|
||||
@ -1415,8 +1415,8 @@ operator!=(const optional<_Tp>& __x, const _Up& __v)
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr
|
||||
enable_if_t<
|
||||
is_convertible_v<decltype(declval<const _Tp&>() !=
|
||||
declval<const _Up&>()), bool>,
|
||||
is_convertible_v<decltype(std::declval<const _Tp&>() !=
|
||||
std::declval<const _Up&>()), bool>,
|
||||
bool
|
||||
>
|
||||
operator!=(const _Tp& __v, const optional<_Up>& __x)
|
||||
@ -1427,8 +1427,8 @@ operator!=(const _Tp& __v, const optional<_Up>& __x)
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr
|
||||
enable_if_t<
|
||||
is_convertible_v<decltype(declval<const _Tp&>() <
|
||||
declval<const _Up&>()), bool>,
|
||||
is_convertible_v<decltype(std::declval<const _Tp&>() <
|
||||
std::declval<const _Up&>()), bool>,
|
||||
bool
|
||||
>
|
||||
operator<(const optional<_Tp>& __x, const _Up& __v)
|
||||
@ -1439,8 +1439,8 @@ operator<(const optional<_Tp>& __x, const _Up& __v)
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr
|
||||
enable_if_t<
|
||||
is_convertible_v<decltype(declval<const _Tp&>() <
|
||||
declval<const _Up&>()), bool>,
|
||||
is_convertible_v<decltype(std::declval<const _Tp&>() <
|
||||
std::declval<const _Up&>()), bool>,
|
||||
bool
|
||||
>
|
||||
operator<(const _Tp& __v, const optional<_Up>& __x)
|
||||
@ -1451,8 +1451,8 @@ operator<(const _Tp& __v, const optional<_Up>& __x)
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr
|
||||
enable_if_t<
|
||||
is_convertible_v<decltype(declval<const _Tp&>() <=
|
||||
declval<const _Up&>()), bool>,
|
||||
is_convertible_v<decltype(std::declval<const _Tp&>() <=
|
||||
std::declval<const _Up&>()), bool>,
|
||||
bool
|
||||
>
|
||||
operator<=(const optional<_Tp>& __x, const _Up& __v)
|
||||
@ -1463,8 +1463,8 @@ operator<=(const optional<_Tp>& __x, const _Up& __v)
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr
|
||||
enable_if_t<
|
||||
is_convertible_v<decltype(declval<const _Tp&>() <=
|
||||
declval<const _Up&>()), bool>,
|
||||
is_convertible_v<decltype(std::declval<const _Tp&>() <=
|
||||
std::declval<const _Up&>()), bool>,
|
||||
bool
|
||||
>
|
||||
operator<=(const _Tp& __v, const optional<_Up>& __x)
|
||||
@ -1475,8 +1475,8 @@ operator<=(const _Tp& __v, const optional<_Up>& __x)
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr
|
||||
enable_if_t<
|
||||
is_convertible_v<decltype(declval<const _Tp&>() >
|
||||
declval<const _Up&>()), bool>,
|
||||
is_convertible_v<decltype(std::declval<const _Tp&>() >
|
||||
std::declval<const _Up&>()), bool>,
|
||||
bool
|
||||
>
|
||||
operator>(const optional<_Tp>& __x, const _Up& __v)
|
||||
@ -1487,8 +1487,8 @@ operator>(const optional<_Tp>& __x, const _Up& __v)
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr
|
||||
enable_if_t<
|
||||
is_convertible_v<decltype(declval<const _Tp&>() >
|
||||
declval<const _Up&>()), bool>,
|
||||
is_convertible_v<decltype(std::declval<const _Tp&>() >
|
||||
std::declval<const _Up&>()), bool>,
|
||||
bool
|
||||
>
|
||||
operator>(const _Tp& __v, const optional<_Up>& __x)
|
||||
@ -1499,8 +1499,8 @@ operator>(const _Tp& __v, const optional<_Up>& __x)
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr
|
||||
enable_if_t<
|
||||
is_convertible_v<decltype(declval<const _Tp&>() >=
|
||||
declval<const _Up&>()), bool>,
|
||||
is_convertible_v<decltype(std::declval<const _Tp&>() >=
|
||||
std::declval<const _Up&>()), bool>,
|
||||
bool
|
||||
>
|
||||
operator>=(const optional<_Tp>& __x, const _Up& __v)
|
||||
@ -1511,8 +1511,8 @@ operator>=(const optional<_Tp>& __x, const _Up& __v)
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr
|
||||
enable_if_t<
|
||||
is_convertible_v<decltype(declval<const _Tp&>() >=
|
||||
declval<const _Up&>()), bool>,
|
||||
is_convertible_v<decltype(std::declval<const _Tp&>() >=
|
||||
std::declval<const _Up&>()), bool>,
|
||||
bool
|
||||
>
|
||||
operator>=(const _Tp& __v, const optional<_Up>& __x)
|
||||
|
||||
@ -1063,7 +1063,7 @@ struct __is_ostreamable : false_type { };
|
||||
|
||||
template <class _Stream, class _Tp>
|
||||
struct __is_ostreamable<_Stream, _Tp, decltype(
|
||||
declval<_Stream>() << declval<_Tp>(), void()
|
||||
std::declval<_Stream>() << std::declval<_Tp>(), void()
|
||||
)> : true_type { };
|
||||
|
||||
template <class _Stream, class _Tp, class = typename enable_if<
|
||||
@ -1113,7 +1113,7 @@ template<class _CharT, class _Traits, class _Yp, class _Dp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if
|
||||
<
|
||||
is_same<void, __void_t<decltype((declval<basic_ostream<_CharT, _Traits>&>() << declval<typename unique_ptr<_Yp, _Dp>::pointer>()))> >::value,
|
||||
is_same<void, __void_t<decltype((std::declval<basic_ostream<_CharT, _Traits>&>() << std::declval<typename unique_ptr<_Yp, _Dp>::pointer>()))> >::value,
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
>::type
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& __p)
|
||||
|
||||
@ -363,7 +363,7 @@ protected:
|
||||
// __outermost
|
||||
|
||||
template <class _Alloc>
|
||||
decltype(declval<_Alloc>().outer_allocator(), true_type())
|
||||
decltype(std::declval<_Alloc>().outer_allocator(), true_type())
|
||||
__has_outer_allocator_test(_Alloc&& __a);
|
||||
|
||||
template <class _Alloc>
|
||||
@ -374,7 +374,7 @@ template <class _Alloc>
|
||||
struct __has_outer_allocator
|
||||
: public common_type
|
||||
<
|
||||
decltype(std::__has_outer_allocator_test(declval<_Alloc&>()))
|
||||
decltype(std::__has_outer_allocator_test(std::declval<_Alloc&>()))
|
||||
>::type
|
||||
{
|
||||
};
|
||||
@ -392,7 +392,7 @@ struct __outermost<_Alloc, true>
|
||||
{
|
||||
typedef __libcpp_remove_reference_t
|
||||
<
|
||||
decltype(declval<_Alloc>().outer_allocator())
|
||||
decltype(std::declval<_Alloc>().outer_allocator())
|
||||
> _OuterAlloc;
|
||||
typedef typename __outermost<_OuterAlloc>::type type;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
|
||||
@ -1229,7 +1229,7 @@ struct __narrowing_check {
|
||||
template <class _Dest>
|
||||
static auto __test_impl(_Dest (&&)[1]) -> __type_identity<_Dest>;
|
||||
template <class _Dest, class _Source>
|
||||
using _Apply _LIBCPP_NODEBUG = decltype(__test_impl<_Dest>({declval<_Source>()}));
|
||||
using _Apply _LIBCPP_NODEBUG = decltype(__test_impl<_Dest>({std::declval<_Source>()}));
|
||||
};
|
||||
|
||||
template <class _Dest, class _Source>
|
||||
@ -1747,7 +1747,7 @@ constexpr void __throw_if_valueless(_Vs&&... __vs) {
|
||||
|
||||
template <
|
||||
class _Visitor, class... _Vs,
|
||||
typename = void_t<decltype(_VSTD::__as_variant(declval<_Vs>()))...> >
|
||||
typename = void_t<decltype(_VSTD::__as_variant(std::declval<_Vs>()))...> >
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
|
||||
constexpr decltype(auto) visit(_Visitor&& __visitor, _Vs&&... __vs) {
|
||||
@ -1760,7 +1760,7 @@ constexpr decltype(auto) visit(_Visitor&& __visitor, _Vs&&... __vs) {
|
||||
#if _LIBCPP_STD_VER > 17
|
||||
template <
|
||||
class _Rp, class _Visitor, class... _Vs,
|
||||
typename = void_t<decltype(_VSTD::__as_variant(declval<_Vs>()))...> >
|
||||
typename = void_t<decltype(_VSTD::__as_variant(std::declval<_Vs>()))...> >
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
|
||||
constexpr _Rp visit(_Visitor&& __visitor, _Vs&&... __vs) {
|
||||
|
||||
@ -7,7 +7,9 @@ find_package(Clang 16)
|
||||
|
||||
set(SOURCES
|
||||
robust_against_adl.cpp
|
||||
libcpp_module.cpp)
|
||||
libcpp_module.cpp
|
||||
qualify_declval.cpp
|
||||
)
|
||||
|
||||
|
||||
if(NOT Clang_FOUND)
|
||||
|
||||
@ -9,12 +9,14 @@
|
||||
#include "clang-tidy/ClangTidyModule.h"
|
||||
#include "clang-tidy/ClangTidyModuleRegistry.h"
|
||||
#include "robust_against_adl.hpp"
|
||||
#include "qualify_declval.hpp"
|
||||
|
||||
namespace {
|
||||
class LibcxxTestModule : public clang::tidy::ClangTidyModule {
|
||||
public:
|
||||
void addCheckFactories(clang::tidy::ClangTidyCheckFactories& check_factories) override {
|
||||
check_factories.registerCheck<libcpp::robust_against_adl_check>("libcpp-robust-against-adl");
|
||||
check_factories.registerCheck<libcpp::qualify_declval>("libcpp-qualify-declval");
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
31
libcxx/test/tools/clang_tidy_checks/qualify_declval.cpp
Normal file
31
libcxx/test/tools/clang_tidy_checks/qualify_declval.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "qualify_declval.hpp"
|
||||
|
||||
namespace {
|
||||
AST_MATCHER(clang::UnresolvedLookupExpr, requiresADL) { return Node.requiresADL(); }
|
||||
AST_MATCHER(clang::UnresolvedLookupExpr, isDeclval) { return Node.getName().getAsString() == "declval"; }
|
||||
} // namespace
|
||||
|
||||
namespace libcpp {
|
||||
qualify_declval::qualify_declval(llvm::StringRef name, clang::tidy::ClangTidyContext* context)
|
||||
: clang::tidy::ClangTidyCheck(name, context) {}
|
||||
|
||||
void qualify_declval::registerMatchers(clang::ast_matchers::MatchFinder* finder) {
|
||||
using namespace clang::ast_matchers;
|
||||
finder->addMatcher(callExpr(has(unresolvedLookupExpr(requiresADL(), isDeclval()))).bind("ADLcall"), this);
|
||||
}
|
||||
|
||||
void qualify_declval::check(const clang::ast_matchers::MatchFinder::MatchResult& result) {
|
||||
if (const auto* call = result.Nodes.getNodeAs<clang::CallExpr>("ADLcall"); call != nullptr) {
|
||||
diag(call->getBeginLoc(), "declval should be qualified to get better error messages")
|
||||
<< clang::FixItHint::CreateInsertion(call->getBeginLoc(), "std::");
|
||||
}
|
||||
}
|
||||
} // namespace libcpp
|
||||
18
libcxx/test/tools/clang_tidy_checks/qualify_declval.hpp
Normal file
18
libcxx/test/tools/clang_tidy_checks/qualify_declval.hpp
Normal file
@ -0,0 +1,18 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clang-tidy/ClangTidyCheck.h"
|
||||
|
||||
namespace libcpp {
|
||||
class qualify_declval : public clang::tidy::ClangTidyCheck {
|
||||
public:
|
||||
qualify_declval(llvm::StringRef, clang::tidy::ClangTidyContext*);
|
||||
void registerMatchers(clang::ast_matchers::MatchFinder*) override;
|
||||
void check(const clang::ast_matchers::MatchFinder::MatchResult&) override;
|
||||
};
|
||||
} // namespace libcpp
|
||||
Loading…
x
Reference in New Issue
Block a user