-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactored buffer and buffer_view #74
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A first brief pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo a few last comments.
include/sparrow/buffer_view.hpp
Outdated
namespace sparrow | ||
{ | ||
/* | ||
* @class buffer_view |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove this and rely on the autobrief syntax?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, I will set up a skeleton for the doc and check whether we can do it in a dedicated PR. If so, I will remove all of them.
using const_reverse_iterator = std::reverse_iterator<const_iterator>; | ||
|
||
explicit buffer_view(buffer<T>& buffer); | ||
buffer_view(pointer p, size_type n); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be complete we also need a subrange(...)
function and a constructor that takes a pair of iterators (they should be template parameters constrained by concept, not buffer_view::iterator
).
These are often used with view types (see std::span
, which also provides first
and last
subview functions).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can do that in a dedicated PR? This piece of code was just moved from the initial buffer.hpp
file. I'll add a todo for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel that this and the iterator pair constructor (which should be what the subrange is built with) not being there makes it incomplete. But ok, it can be added in another PR although please do it immediately after this one then?
* @brief Object that references but does not own a piece of contiguous memory | ||
*/ | ||
template <class T> | ||
class buffer_view |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this type different from std::span
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are very similar indeed. However, std::span
is missing some APIs in C++20 (like cbegin
/ cend
), and we may want to provide additional std;:vector like APIs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add that clarification in the comments, so that we keep a trace in the code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM up to file formatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the details I pointed LGTM
Fix #45