4

I know there is concept for ContiguousIterator in words specification sense, but I wonder if it can be written using C++20/C++17 Concepts TS syntax.

My problem with this is that unlike RandomAccessIterator ContiguousIterator requires not just some operations like it+123 to work, but depends on runtime result of that operation.

NoSenseEtAl
  • 28,205
  • 28
  • 128
  • 277

2 Answers2

2

No you cannot, not without a traits class or other helper, where types opt-in to being contiguous.

Yakk - Adam Nevraumont
  • 262,606
  • 27
  • 330
  • 524
2

Your problem is currently unsolvable. The committee is considering what to do about deducing contiguous memory access. The flub is that iterator_category is not a trait (although it resides in iterator_traits); It is an ad-hoc type. It cannot be subtyped without breaking existing code. (Beginner mistake, eh what?) The Committee has recognized the mess. This recent discussion tells all -> How to deduce contiguous memory from iterator

Jive Dadson
  • 16,680
  • 9
  • 52
  • 65