[libcxx-commits] [PATCH] D101922: [libcxx][iterator] adds `std::ranges::advance`

Christopher Di Bella via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 5 09:52:42 PDT 2021


cjdb added inline comments.


================
Comment at: libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.advance/advance.verify.cpp:87-95
+void standard_function_properties() {
+  &std::ranges::advance; // expected-error {{overload resolution selected deleted operator '&'}}
+  auto move = std::move(std::ranges::advance);
+  // expected-error at -1{{call to implicitly-deleted copy constructor of 'std::__1::ranges::__advance_fn'}}
+  auto copy = std::ranges::advance;
+  // expected-error at -1{{call to implicitly-deleted copy constructor of 'std::__1::ranges::__advance_fn'}}
+  decltype(std::ranges::advance) x;                    // expected-error {{}}
----------------
I'm toying with the idea of replacing this with
```
// in some header
template<class T>
inline constexpr bool not_addressable = !requires(T& t) { &t; };

template<class T>
[[nodiscard]] consteval bool standard_function_properties()
{
  static_assert(!not_addressable<T>);
  static_assert(!not_addressable<T const>);

  static_assert(!std::default_initializable<advance_t>);

  static_assert(!std::move_constructible<advance_t>);
  static_assert(!std::assignable<advance_t&, advance_t>);
  static_assert(!std::assignable<advance_t&, advance_t const>);

  static_assert(!std::copy_constructible<advance_t>);
  static_assert(!std::assignable<advance_t&, advance_t&>);
  static_assert(!std::assignable<advance_t&, advance_t const&>);

  static_assert(std::is_final_v<advance_t>);
}

// in this file
static_assert(std::remove_cv_t<decltype(std::ranges::advance)>);
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101922/new/

https://reviews.llvm.org/D101922



More information about the libcxx-commits mailing list