[flang-commits] [libunwind] [lldb] [flang] [libc] [llvm] [clang-tools-extra] [clang] [libcxx] [compiler-rt] [libc++] Implement ranges::iota (PR #68494)

Christopher Di Bella via flang-commits flang-commits at lists.llvm.org
Fri Jan 5 14:16:04 PST 2024


================
@@ -1083,6 +1083,27 @@ rvalue_iterator(T*) -> rvalue_iterator<T>;
 
 static_assert(std::random_access_iterator<rvalue_iterator<int*>>);
 
+// The ProxyDiffTBase allows us to conditionally specify Proxy<T>::difference_type
+// which we need in certain situations. For example when we want
+// std::weakly_incrementable<Proxy<T>> to be true.
+template <class T>
+struct ProxyDiffTBase {};
+
+template <class T>
+  requires requires { std::iter_difference_t<T>{}; }
+struct ProxyDiffTBase<T> {
+  using difference_type = std::iter_difference_t<T>;
+};
+
+// These concepts allow us to conditionally add the pre-/postfix operators
+// when T also supports those member functions. Like ProxyDiffTBase, this
+// is necessary when we want std::weakly_incrementable<Proxy<T>> to be true.
+template <class T>
+concept HasPreIncrementOp = requires(T const& obj) { ++obj; };
+
+template <class T>
+concept HasPostIncrementOp = requires(T const& obj) { obj++; };
+
----------------
cjdb wrote:

These may be better off in a local header, since they're very `ranges::iota`-specific.

https://github.com/llvm/llvm-project/pull/68494


More information about the flang-commits mailing list