[libcxx-commits] [PATCH] D106708: [libc++] Add range_size_t
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jul 23 13:47:33 PDT 2021
ldionne updated this revision to Diff 361336.
ldionne added a comment.
Update with review link.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D106708/new/
https://reviews.llvm.org/D106708
Files:
libcxx/docs/Status/RangesPaper.csv
libcxx/include/__ranges/concepts.h
libcxx/include/ranges
libcxx/test/std/ranges/range.req/range.range/range_size_t.compile.pass.cpp
Index: libcxx/test/std/ranges/range.req/range.range/range_size_t.compile.pass.cpp
===================================================================
--- /dev/null
+++ libcxx/test/std/ranges/range.req/range.range/range_size_t.compile.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: libcpp-no-concepts
+// UNSUPPORTED: gcc-10
+
+// template<sized_range R>
+// using range_size_t = decltype(ranges::size(declval<R&>()));
+
+#include <ranges>
+#include <concepts>
+
+#include "test_iterators.h"
+#include "test_range.h"
+
+struct Range {
+ cpp17_input_iterator<int*> begin();
+ sentinel end();
+ short size() const;
+};
+
+static_assert(std::same_as<std::ranges::range_size_t<Range>, short>);
Index: libcxx/include/ranges
===================================================================
--- libcxx/include/ranges
+++ libcxx/include/ranges
@@ -35,14 +35,14 @@
template<class T>
inline constexpr bool enable_borrowed_range = false;
- template<class T>
- using iterator_t = decltype(ranges::begin(declval<T&>()));
- template<class T>
- using iterator_t = decltype(ranges::begin(declval<T&>()));
+ template<class R>
+ using iterator_t = decltype(ranges::begin(declval<R&>()));
template<range R>
using sentinel_t = decltype(ranges::end(declval<R&>()));
template<range R>
using range_difference_t = iter_difference_t<iterator_t<R>>;
+ template<sized_range R>
+ using range_size_t = decltype(ranges::size(declval<R&>()));
template<range R>
using range_value_t = iter_value_t<iterator_t<R>>;
template<range R>
Index: libcxx/include/__ranges/concepts.h
===================================================================
--- libcxx/include/__ranges/concepts.h
+++ libcxx/include/__ranges/concepts.h
@@ -69,6 +69,9 @@
template <class _Tp>
concept sized_range = range<_Tp> && requires(_Tp& __t) { ranges::size(__t); };
+ template<sized_range _Rp>
+ using range_size_t = decltype(ranges::size(declval<_Rp&>()));
+
// `disable_sized_range` defined in `<__ranges/size.h>`
// [range.view], views
Index: libcxx/docs/Status/RangesPaper.csv
===================================================================
--- libcxx/docs/Status/RangesPaper.csv
+++ libcxx/docs/Status/RangesPaper.csv
@@ -103,10 +103,10 @@
| `ranges::iterator_t <https://llvm.org/D100255>`_
| `ranges::sentinel_t <https://llvm.org/D100269>`_
| `ranges::range_difference_t <https://llvm.org/D100269>`_
-| ranges::range_size_t
+| `ranges::range_size_t <https://llvm.org/D106708>`_
| `ranges::range_value_t <https://llvm.org/D100269>`_
| `ranges::range_reference_t <https://llvm.org/D100269>`_
-| `ranges::range_rvalue_reference_t <https://llvm.org/D100269>`_",[range.access],Christopher Di Bella,In progress
+| `ranges::range_rvalue_reference_t <https://llvm.org/D100269>`_",[range.access],Christopher Di Bella,✅
`[range.sized] <http://wg21.link/range.sized>`_,"| `ranges::sized_range <https://llvm.org/D102434>`_
| `ranges::disable_sized_range <https://llvm.org/D102434>`_","| [range.primitives]
| [range.range]",Christopher Di Bella,✅
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106708.361336.patch
Type: text/x-patch
Size: 3495 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210723/49f669f2/attachment-0001.bin>
More information about the libcxx-commits
mailing list