Skip to content
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

Merged
merged 10 commits into from
Apr 18, 2024
Merged

Conversation

JohanMabille
Copy link
Collaborator

Fix #45

Copy link
Collaborator

@jjerphan jjerphan left a 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.

include/sparrow/buffer.hpp Outdated Show resolved Hide resolved
include/sparrow/buffer.hpp Outdated Show resolved Hide resolved
include/sparrow/buffer.hpp Outdated Show resolved Hide resolved
include/sparrow/buffer.hpp Outdated Show resolved Hide resolved
include/sparrow/buffer.hpp Show resolved Hide resolved
include/sparrow/buffer.hpp Show resolved Hide resolved
Copy link
Collaborator

@jjerphan jjerphan left a 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.hpp Outdated Show resolved Hide resolved
include/sparrow/buffer.hpp Show resolved Hide resolved
include/sparrow/buffer.hpp Show resolved Hide resolved
include/sparrow/buffer.hpp Outdated Show resolved Hide resolved
include/sparrow/buffer_view.hpp Outdated Show resolved Hide resolved
namespace sparrow
{
/*
* @class buffer_view
Copy link
Collaborator

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?

Copy link
Collaborator Author

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);
Copy link
Collaborator

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).

Copy link
Collaborator Author

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.

Copy link
Collaborator

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?

include/sparrow/buffer_view.hpp Outdated Show resolved Hide resolved
include/sparrow/buffer_view.hpp Show resolved Hide resolved
* @brief Object that references but does not own a piece of contiguous memory
*/
template <class T>
class buffer_view
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

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?

test/test_buffer.cpp Show resolved Hide resolved
test/test_buffer.cpp Show resolved Hide resolved
include/sparrow/dynamic_bitset.hpp Show resolved Hide resolved
Copy link
Collaborator

@jjerphan jjerphan left a 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.

Copy link
Collaborator

@Klaim Klaim left a 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

@JohanMabille JohanMabille merged commit a1e1b95 into man-group:main Apr 18, 2024
21 checks passed
@JohanMabille JohanMabille deleted the buffer branch April 18, 2024 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor buffer internal representation
3 participants