[libcxx-commits] [PATCH] D100073: [libcxx] adds `std::indirectly_readable` to <iterator>

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Apr 20 10:36:25 PDT 2021


Quuxplusone added a comment.

Re @zoecarver's comment about `value_type = void`: I observe that `std::ostream_iterator<int>` is such a legacy output iterator today. However, please add a test that uses a simpler type, because I don't trust `ostream_iterator` to //continue// providing a `value_type` member for the next decade.

The Standard's wording is sadly very opaque and confusing and scattered all over [iterators]; I'm not sure how to achieve a type with `value_type = void` that doesn't fall foul of many other constraints. //Maybe// something like this:

  struct ValueTypeVoid {
      using value_type = void;
      using iterator_category = std::output_iterator_tag;
      using pointer = void*;
      using reference = int&;
      using difference_type = int;
  };
  static_assert(std::same_as<std::iter_value_t<ValueTypeVoid>, void>);
  static_assert(!std::indirectly_readable<ValueTypeVoid>);
  static_assert(!requires { typename std::iter_reference_t<ValueTypeVoid> });  // or whatever one has to type to make this work

Of course anything with `value_type = void` can't be `indirectly_readable`, because the definition of `indirectly_readable` requires forming `iter_value_t<In>&` as part of its common-reference checks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100073



More information about the libcxx-commits mailing list