[libcxx-commits] [libcxx] 3042091 - [libc++] [ranges] Whitespace and namespace-style adjustments. NFC.
Arthur O'Dwyer via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Dec 23 11:56:40 PST 2021
Author: Arthur O'Dwyer
Date: 2021-12-23T14:56:23-05:00
New Revision: 3042091168e99323217223a959df8675bdfa9b3c
URL: https://github.com/llvm/llvm-project/commit/3042091168e99323217223a959df8675bdfa9b3c
DIFF: https://github.com/llvm/llvm-project/commit/3042091168e99323217223a959df8675bdfa9b3c.diff
LOG: [libc++] [ranges] Whitespace and namespace-style adjustments. NFC.
Largely split out of D116199 to keep that PR smaller.
Added:
Modified:
libcxx/include/__ranges/access.h
libcxx/include/__ranges/data.h
libcxx/include/__ranges/empty.h
libcxx/include/__ranges/size.h
Removed:
################################################################################
diff --git a/libcxx/include/__ranges/access.h b/libcxx/include/__ranges/access.h
index c58849f7cf33b..91dc3055c86da 100644
--- a/libcxx/include/__ranges/access.h
+++ b/libcxx/include/__ranges/access.h
@@ -29,11 +29,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD
namespace ranges {
template <class _Tp>
concept __can_borrow =
- is_lvalue_reference_v<_Tp> || enable_borrowed_range<remove_cvref_t<_Tp> >;
+ is_lvalue_reference_v<_Tp> || enable_borrowed_range<remove_cvref_t<_Tp>>;
} // namespace ranges
// [range.access.begin]
-namespace ranges::__begin {
+
+namespace ranges {
+namespace __begin {
template <class _Tp>
concept __member_begin =
__can_borrow<_Tp> &&
@@ -48,7 +50,7 @@ namespace ranges::__begin {
concept __unqualified_begin =
!__member_begin<_Tp> &&
__can_borrow<_Tp> &&
- __class_or_enum<remove_cvref_t<_Tp> > &&
+ __class_or_enum<remove_cvref_t<_Tp>> &&
requires(_Tp && __t) {
{ _LIBCPP_AUTO_CAST(begin(__t)) } -> input_or_output_iterator;
};
@@ -62,42 +64,47 @@ namespace ranges::__begin {
}
template <class _Tp>
- requires __member_begin<_Tp>
+ requires __member_begin<_Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
- noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.begin())))
+ noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.begin())))
{
return _LIBCPP_AUTO_CAST(__t.begin());
}
template <class _Tp>
- requires __unqualified_begin<_Tp>
+ requires __unqualified_begin<_Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
- noexcept(noexcept(_LIBCPP_AUTO_CAST(begin(__t))))
+ noexcept(noexcept(_LIBCPP_AUTO_CAST(begin(__t))))
{
return _LIBCPP_AUTO_CAST(begin(__t));
}
void operator()(auto&&) const = delete;
};
-} // namespace ranges::__begin
+}
-namespace ranges {
- inline namespace __cpo {
- inline constexpr auto begin = __begin::__fn{};
- } // namespace __cpo
+inline namespace __cpo {
+ inline constexpr auto begin = __begin::__fn{};
+} // namespace __cpo
+} // namespace ranges
+// [range.range]
+
+namespace ranges {
template <class _Tp>
using iterator_t = decltype(ranges::begin(declval<_Tp&>()));
} // namespace ranges
// [range.access.end]
-namespace ranges::__end {
+
+namespace ranges {
+namespace __end {
template <class _Tp>
concept __member_end =
__can_borrow<_Tp> &&
requires(_Tp&& __t) {
typename iterator_t<_Tp>;
- { _LIBCPP_AUTO_CAST(__t.end()) } -> sentinel_for<iterator_t<_Tp> >;
+ { _LIBCPP_AUTO_CAST(__t.end()) } -> sentinel_for<iterator_t<_Tp>>;
};
void end(auto&) = delete;
@@ -107,10 +114,10 @@ namespace ranges::__end {
concept __unqualified_end =
!__member_end<_Tp> &&
__can_borrow<_Tp> &&
- __class_or_enum<remove_cvref_t<_Tp> > &&
+ __class_or_enum<remove_cvref_t<_Tp>> &&
requires(_Tp && __t) {
typename iterator_t<_Tp>;
- { _LIBCPP_AUTO_CAST(end(__t)) } -> sentinel_for<iterator_t<_Tp> >;
+ { _LIBCPP_AUTO_CAST(end(__t)) } -> sentinel_for<iterator_t<_Tp>>;
};
class __fn {
@@ -123,76 +130,85 @@ namespace ranges::__end {
}
template <class _Tp>
- requires __member_end<_Tp>
+ requires __member_end<_Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
- noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.end())))
+ noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.end())))
{
return _LIBCPP_AUTO_CAST(__t.end());
}
template <class _Tp>
- requires __unqualified_end<_Tp>
+ requires __unqualified_end<_Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
- noexcept(noexcept(_LIBCPP_AUTO_CAST(end(__t))))
+ noexcept(noexcept(_LIBCPP_AUTO_CAST(end(__t))))
{
return _LIBCPP_AUTO_CAST(end(__t));
}
void operator()(auto&&) const = delete;
};
-} // namespace ranges::__end
+}
-namespace ranges::inline __cpo {
+inline namespace __cpo {
inline constexpr auto end = __end::__fn{};
-} // namespace ranges::__cpo
+} // namespace __cpo
+} // namespace ranges
+
+// [range.access.cbegin]
-namespace ranges::__cbegin {
+namespace ranges {
+namespace __cbegin {
struct __fn {
template <class _Tp>
- requires invocable<decltype(ranges::begin), _Tp const&>
+ requires invocable<decltype(ranges::begin), _Tp const&>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp& __t) const
- noexcept(noexcept(ranges::begin(_VSTD::as_const(__t))))
+ noexcept(noexcept(ranges::begin(_VSTD::as_const(__t))))
{
return ranges::begin(_VSTD::as_const(__t));
}
template <class _Tp>
- requires is_rvalue_reference_v<_Tp> && invocable<decltype(ranges::begin), _Tp const&&>
+ requires is_rvalue_reference_v<_Tp> && invocable<decltype(ranges::begin), _Tp const&&>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
- noexcept(noexcept(ranges::begin(static_cast<_Tp const&&>(__t))))
+ noexcept(noexcept(ranges::begin(static_cast<_Tp const&&>(__t))))
{
return ranges::begin(static_cast<_Tp const&&>(__t));
}
};
-} // namespace ranges::__cbegin
+}
-namespace ranges::inline __cpo {
+inline namespace __cpo {
inline constexpr auto cbegin = __cbegin::__fn{};
-} // namespace ranges::__cpo
+} // namespace __cpo
+} // namespace ranges
-namespace ranges::__cend {
+// [range.access.cend]
+
+namespace ranges {
+namespace __cend {
struct __fn {
template <class _Tp>
- requires invocable<decltype(ranges::end), _Tp const&>
+ requires invocable<decltype(ranges::end), _Tp const&>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp& __t) const
- noexcept(noexcept(ranges::end(_VSTD::as_const(__t))))
+ noexcept(noexcept(ranges::end(_VSTD::as_const(__t))))
{
return ranges::end(_VSTD::as_const(__t));
}
template <class _Tp>
- requires is_rvalue_reference_v<_Tp> && invocable<decltype(ranges::end), _Tp const&&>
+ requires is_rvalue_reference_v<_Tp> && invocable<decltype(ranges::end), _Tp const&&>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
- noexcept(noexcept(ranges::end(static_cast<_Tp const&&>(__t))))
+ noexcept(noexcept(ranges::end(static_cast<_Tp const&&>(__t))))
{
return ranges::end(static_cast<_Tp const&&>(__t));
}
};
-} // namespace ranges::__cend
+}
-namespace ranges::inline __cpo {
+inline namespace __cpo {
inline constexpr auto cend = __cend::__fn{};
-} // namespace ranges::__cpo
+} // namespace __cpo
+} // namespace ranges
#endif // !defined(_LIBCPP_HAS_NO_RANGES)
diff --git a/libcxx/include/__ranges/data.h b/libcxx/include/__ranges/data.h
index a33da0e5a1c24..cc151c59f3d78 100644
--- a/libcxx/include/__ranges/data.h
+++ b/libcxx/include/__ranges/data.h
@@ -26,8 +26,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if !defined(_LIBCPP_HAS_NO_RANGES)
-namespace ranges {
// [range.prim.data]
+
+namespace ranges {
namespace __data {
template <class _Tp>
concept __ptr_to_object = is_pointer_v<_Tp> && is_object_v<remove_pointer_t<_Tp>>;
@@ -64,7 +65,7 @@ namespace __data {
return _VSTD::to_address(ranges::begin(_VSTD::forward<_Tp>(__t)));
}
};
-} // end namespace __data
+}
inline namespace __cpo {
inline constexpr auto data = __data::__fn{};
diff --git a/libcxx/include/__ranges/empty.h b/libcxx/include/__ranges/empty.h
index 4c6a3a0d24ff0..e8a8aabf4aed6 100644
--- a/libcxx/include/__ranges/empty.h
+++ b/libcxx/include/__ranges/empty.h
@@ -23,8 +23,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if !defined(_LIBCPP_HAS_NO_RANGES)
-namespace ranges {
// [range.prim.empty]
+
+namespace ranges {
namespace __empty {
template <class _Tp>
concept __member_empty = requires(_Tp&& __t) {
diff --git a/libcxx/include/__ranges/size.h b/libcxx/include/__ranges/size.h
index c37467eaf747c..fc6641cf4887b 100644
--- a/libcxx/include/__ranges/size.h
+++ b/libcxx/include/__ranges/size.h
@@ -26,10 +26,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if !defined(_LIBCPP_HAS_NO_RANGES)
namespace ranges {
-template<class>
-inline constexpr bool disable_sized_range = false;
+ template<class>
+ inline constexpr bool disable_sized_range = false;
+}
// [range.prim.size]
+
+namespace ranges {
namespace __size {
void size(auto&) = delete;
void size(const auto&) = delete;
@@ -90,18 +93,23 @@ namespace __size {
return _VSTD::__to_unsigned_like(ranges::end(__t) - ranges::begin(__t));
}
};
-} // end namespace __size
+}
inline namespace __cpo {
inline constexpr auto size = __size::__fn{};
} // namespace __cpo
+} // namespace ranges
+
+// [range.prim.ssize]
+namespace ranges {
namespace __ssize {
struct __fn {
template<class _Tp>
requires requires (_Tp&& __t) { ranges::size(__t); }
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr integral auto operator()(_Tp&& __t) const
- noexcept(noexcept(ranges::size(__t))) {
+ noexcept(noexcept(ranges::size(__t)))
+ {
using _Signed = make_signed_t<decltype(ranges::size(__t))>;
if constexpr (sizeof(ptr
diff _t) > sizeof(_Signed))
return static_cast<ptr
diff _t>(ranges::size(__t));
More information about the libcxx-commits
mailing list