-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix is_buffer_sequence #403
base: master
Are you sure you want to change the base?
Fix is_buffer_sequence #403
Conversation
Have not looked at the implementation yet, will do so, but before that.
Are these statements not contradicting themselves? from the first two quote we can clearly see that there is no dependency (currently) on |
d855e3d
to
fb247ee
Compare
Still, I don't think I will use the word |
I agree,
|
bf716ee
to
6aaac4d
Compare
|
template <typename T> | ||
static result<sizeof( | ||
|
||
is_same_as<std::size_t>(declval<T>().size()), |
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.
Perhaps we should make this check (and other similar checks) more strict:
is_same_as<std::size_t>(declval<T>().size()), | |
is_same_as<std::size_t>(declval<const T>().size()), |
And also to relax the return type requirement:
is_same_as<std::size_t>(declval<T>().size()), | |
is_convertible_to<std::size_t>(declval<T>().size()), |
Almost completely reworked
is_buffer_sequence
implementation is intended to fix issues from #402 (and to satisfy the corresponding test). It is also more concise, since it does not introduce several helper declarations for each individual check. A few helper declarations of general use are placed in the separate header file.This PR obsoletes #402, however, some comments still can be found there.
Here is "rebased" branch containing all the stuff of this PR presented as two independent changesets (I would prefer not to force-push yet again). The first one is the test from #402; this second contains proposed fixes.
Original logic behind the
is_buffer_sequence
template for all types exceptmutable_buffer
andconst_buffer
is guessed as follows:decltype
is available, the typeX
is considered as MutableBufferSequence if the result of the expression*begin_buffer_sequence(x)
can be converted tomutable_buffer
andend_buffer_sequence(x)
returns non-void. Said functions in general case return the same as corresponding member functions, so the reqiurements above can be applied to expressions*x.begin()
andx.end()
.decltype
is unavailable or disabled, the typeX
is considered as MutableBufferSequence if it has the following: members namedbegin
andend
(not nessesary the functions); nested types or typedefsconst_iterator
andvalue_type
. The latter type also has to be convertible tomutable_buffer
.Reqiurements for ConstBufferSequence are similar.
The logic described is implemented incorrectly; test cases and possible fixes are proposed in #402. This logic is also not perfect. Some obvious checks in #402 still fail.
The proposed variant implements the following set of requirements for MutableBufferSequence and ConstBufferSequence (with no dependency on the avaliability of
decltype
):*begin_buffer_sequence(x)
has to be convertible to the corresponding buffer type (mutable_buffer
orconst_buffer
).*end_buffer_sequence(x)
has to be convertible to the corresponding buffer type.Nested type
const_iterator
(and alsoiterator
) will be checked indirectly through declarations ofbegin_buffer_sequence
andend_buffer_sequence
when necessary (it may be necessary only whendecltype
is unavailable).