cplusplus / draft

C++ standards drafts
http://www.open-std.org/jtc1/sc22/wg21/
5.69k stars 749 forks source link

[range.chunk.by.view] Should the help function `find-next`/`find-prev` of `chunk_by_view` be `private`? #5484

Open hewillk opened 2 years ago

hewillk commented 2 years ago

From [range.chunk.by.view]

namespace std::ranges {
template<forward_range V, indirect_­binary_­predicate<iterator_t<V>, iterator_t<V>> Pred>
  requires view<V> && is_object_v<Pred>
class chunk_by_view : public view_interface<chunk_by_view<V, Pred>> {
  // ...

public:
  chunk_by_view() requires default_­initializable<V> && default_­initializable<Pred> = default;
  constexpr explicit chunk_by_view(V base, Pred pred);

  constexpr V base() const & requires copy_­constructible<V> { return base_; }
  constexpr V base() && { return std::move(base_); }

  constexpr const Pred& pred() const;

  constexpr iterator begin();
  constexpr auto end();

  constexpr iterator_t<V> find-next(iterator_t<V>);                 // exposition only
  constexpr iterator_t<V> find-prev(iterator_t<V>)                  // exposition only
    requires bidirectional_­range<V>;
};

Although find-next and find-prev are exposition only, is it more appropriate to move them to the private block?

frederick-vs-ja commented 1 year ago

They are used in "Effects: Equivalent to" in the specification of the iterator. It seems to me that the reason of making them public is to avoid the potentially ill-formedness caused by access control.

I guess there should be a general rule - exposition-only members in the library specification are considered accessible from other entities in the standard library, but not from programs (user codes).

JohelEGP commented 1 year ago

I guess there should be a general rule - exposition-only members in the library specification are considered accessible from other entities in the standard library, but not from programs (user codes).

See https://github.com/cplusplus/draft/issues/5428#issuecomment-1116721544.