{ _VSTD::to_address(__i) } -> same_as<add_pointer_t<iter_reference_t<_Ip>>>;
};
+
+template<class _Ip>
+concept __has_arrow = input_iterator<_Ip> && (is_pointer_v<_Ip> || requires(_Ip __i) { __i.operator->(); });
+
// clang-format on
#endif // !defined(_LIBCPP_HAS_NO_RANGES)
// Otherwise, if `decltype(declval<I&>().operator->())` is well-formed, then `pointer` names that
// type.
template<class _Ip>
-concept __has_arrow =
- requires(_Ip& __i) {
- __i.operator->();
- };
-
-template<class _Ip>
- requires __has_arrow<_Ip> && (!__has_member_pointer<_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->());
};
default_initializable<_Tp> &&
enable_view<_Tp>;
+template<class _Range>
+concept __simple_view =
+ view<_Range> && range<const _Range> &&
+ same_as<iterator_t<_Range>, iterator_t<const _Range>> &&
+ same_as<sentinel_t<_Range>, iterator_t<const _Range>>;
} // end namespace ranges
#endif // !_LIBCPP_HAS_NO_RANGES
template<class _Rp, class _Tp, class _Up>
concept strict_weak_order = relation<_Rp, _Tp, _Up>;
+template<class _Tp, class _Up>
+concept __different_from = !same_as<remove_cvref_t<_Tp>, remove_cvref_t<_Up>>;
+
#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS)
_LIBCPP_END_NAMESPACE_STD
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <ranges>
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: libcpp-no-concepts
+// UNSUPPORTED: gcc-10
+
+#include <ranges>
+
+#include "test_macros.h"
+
+static_assert(std::__different_from<int, char>);
+static_assert(std::__different_from<const int, char>);
+static_assert(!std::__different_from<const int, int>);
+static_assert(!std::__different_from<const volatile int, int>);
+static_assert(!std::__different_from<const int&, int>);
+static_assert(!std::__different_from<int&, int>);
+static_assert(!std::__different_from<int&&, int>);
+static_assert(!std::__different_from<int, int&>);
+static_assert(!std::__different_from<int&, const int&>);
+static_assert(!std::__different_from<int(&)(), int()>);
+static_assert(std::__different_from<int(&)(), int(*)()>);
+
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <ranges>
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: libcpp-no-concepts
+// UNSUPPORTED: gcc-10
+
+#include <ranges>
+
+#include "test_macros.h"
+
+struct simple_iter {
+ typedef std::input_iterator_tag iterator_category;
+ typedef int value_type;
+ typedef std::ptrdiff_t difference_type;
+ typedef int* pointer;
+ typedef int& reference;
+
+ reference operator*() const;
+ pointer operator->() const;
+ friend bool operator==(const simple_iter&, const simple_iter&);
+ friend bool operator< (const simple_iter&, const simple_iter&);
+ friend bool operator<=(const simple_iter&, const simple_iter&);
+ friend bool operator> (const simple_iter&, const simple_iter&);
+ friend bool operator>=(const simple_iter&, const simple_iter&);
+
+ simple_iter& operator++();
+ simple_iter operator++(int);
+};
+
+struct no_star {
+ typedef std::input_iterator_tag iterator_category;
+ typedef int value_type;
+ typedef std::ptrdiff_t difference_type;
+ typedef int* pointer;
+ typedef int& reference;
+
+ /* reference operator*() const; */
+ pointer operator->() const;
+ friend bool operator==(const simple_iter&, const simple_iter&);
+ friend bool operator< (const simple_iter&, const simple_iter&);
+ friend bool operator<=(const simple_iter&, const simple_iter&);
+ friend bool operator> (const simple_iter&, const simple_iter&);
+ friend bool operator>=(const simple_iter&, const simple_iter&);
+
+ simple_iter& operator++();
+ simple_iter operator++(int);
+};
+
+struct no_arrow {
+ typedef std::input_iterator_tag iterator_category;
+ typedef int value_type;
+ typedef std::ptrdiff_t difference_type;
+ typedef int* pointer;
+ typedef int& reference;
+
+ reference operator*() const;
+ /* pointer operator->() const; */
+ friend bool operator==(const simple_iter&, const simple_iter&);
+ friend bool operator< (const simple_iter&, const simple_iter&);
+ friend bool operator<=(const simple_iter&, const simple_iter&);
+ friend bool operator> (const simple_iter&, const simple_iter&);
+ friend bool operator>=(const simple_iter&, const simple_iter&);
+
+ simple_iter& operator++();
+ simple_iter operator++(int);
+};
+
+struct E {};
+struct Incomplete;
+
+static_assert(std::__has_arrow<int*>);
+static_assert(std::__has_arrow<E*>);
+static_assert(!std::__has_arrow<Incomplete*>); // Because it's not an input_iterator.
+static_assert(std::__has_arrow<simple_iter>);
+static_assert(!std::__has_arrow<no_star>);
+static_assert(!std::__has_arrow<no_arrow>);
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <ranges>
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: libcpp-no-concepts
+// UNSUPPORTED: gcc-10
+
+#include <ranges>
+
+#include "test_macros.h"
+#include "test_iterators.h"
+
+struct SimpleView : std::ranges::view_base {
+ friend int* begin(SimpleView&);
+ friend int* begin(SimpleView const&);
+ friend int* end(SimpleView&);
+ friend int* end(SimpleView const&);
+};
+
+struct WrongConstView : std::ranges::view_base {
+ friend int* begin(WrongConstView&);
+ friend const int* begin(WrongConstView const&);
+ friend int* end(WrongConstView&);
+ friend const int* end(WrongConstView const&);
+};
+
+struct NoConstView : std::ranges::view_base {
+ friend int* begin(NoConstView&);
+ friend int* end(NoConstView&);
+};
+
+struct DifferentSentinel : std::ranges::view_base {
+ friend int* begin(DifferentSentinel&);
+ friend int* begin(DifferentSentinel const&);
+ friend sentinel_wrapper<int*> end(DifferentSentinel&);
+ friend sentinel_wrapper<int*> end(DifferentSentinel const&);
+};
+
+static_assert( std::ranges::__simple_view<SimpleView>);
+static_assert(!std::ranges::__simple_view<WrongConstView>);
+static_assert(!std::ranges::__simple_view<NoConstView>);
+static_assert(!std::ranges::__simple_view<DifferentSentinel>);