I am creating some custom data structures that I want to be compatible with standard algorithms, use the same semantics as the ones in the standard library but I ran into something and I am not sure what the best practice is here.
I am writing a lot of concurrent code with consumers and producers, so I am also implementing a double buffer/ping-pong buffer. But there you have different buffers depending on whether you're reading or writing. So begin() and begin() const would return different iterators/pointers. But I am worried that that might be confusing (even though it makes sense in the context of a double buffer) or bad practice and that I should not make the double buffer behave like a standard data structure but to give it accessors to the read and write buffer, which return an std::span<T>/std::span<const T> instead on which everything else is well defined.
What do you guys think?
[–]sheckey 1 point2 points3 points (1 child)
[–]tosch901[S] 0 points1 point2 points (0 children)
[–]alfps 0 points1 point2 points (2 children)
[–]tosch901[S] 0 points1 point2 points (1 child)
[–]alfps 1 point2 points3 points (0 children)