-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: initial CPOs for representation types and their usage in re…
…presentation concepts
- Loading branch information
Showing
2 changed files
with
110 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f84ed8f
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.
It has come to my attention that the representation concepts do not requrie the implicit expression variations.
That's because the
requires
's parameters have typeT
and notconst T&
.f84ed8f
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.
Also, the CPOs seem to be lacking https://eel.is/c++draft/customization.point.object#6,
which instead are in the concepts.
f84ed8f
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 am not sure what you mean here.
If concepts are defined in terms of CPOs, then CPOs probably can't use those concepts to constrain the return type. It is like trying to constrain
std::ranges::swap
arguments withstd::swappable
.Can you provide some examples or submit a PR with the changes you would like to see?
f84ed8f
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.
Please note that the intent is to remove
is_scalar
anddetail::Scalar
& Co. As you suggested some time ago, if it is only possible, we should remove those and replace them with just syntactic checks on a type.f84ed8f
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.
std::ranges::range
is defined as (https://eel.is/c++draft/range.range):It has the requirement
ranges::begin(t);
rather than
{ ranges::begin(t) } -> input_or_output_range;
.ranges::begin
itself requires its result to be aninput_or_output_range
.f84ed8f
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.
f84ed8f
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.
Do these poison pills need to be specified like
https://eel.is/c++draft/concept.swappable#2.1 or
https://eel.is/c++draft/range.access.begin#2.5?
Also, for these to be CPOs, they need to be constrained to meet https://eel.is/c++draft/customization.point.object#4.sentence-2.
f84ed8f
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.
Sure, but
begin()
is not constrained withrange
.f84ed8f
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.
My intent was to constrain concepts with CPO invocation (like
swappable
). In this case, the argument and return type can't be constrained by the same concept. If something supportsnorm
it is aVectorRepresentation
. If something supportsre
andim
, it isComplexRepresentation
. I do not know how to constrain the input with the same concept as well. Maybe we can constrain the output withScalarRepresentation
in such a case, but it means that we will have to split and intermix all the concepts and customization points definitions, which I am not sure if I like.f84ed8f
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.
If you know how to resolve the above cyclic constraints, please share a PR. Please note, that what we have is still not the final version as we still depend on
is_xxx
customization points. We will eventually remove those, but to do that, I need to implement proper handling of quantity specs for various representations.f84ed8f
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.
Please note that all return
auto
. For unsupported cases, nothing is returned, which means that the return type can't be deduced.f84ed8f
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 don't see any cycle, just like the C++ Standard CPOs don't have any.
It deduces to
void
,and doesn't meet the requirements of the CPO
(e.g., for
mp_units::real
to return the real part).f84ed8f
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 am not sure. The idea is to force the name lookup to only use ADL and not scope resolution. We do not want to look for overloads in the parent scopes and the global scope.
f84ed8f
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.
Don't forget about f84ed8f#commitcomment-149469198.
f84ed8f
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 am not sure what you meant in this comment. Can you provide some example?
f84ed8f
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.
mp-units/src/core/include/mp-units/framework/representation_concepts.h
Lines 78 to 80 in d6002ce
This
-a
requires a modifiable lvaluea
.-T{}
is not required, or any other combination that is not a non-const lvalue.If the parameter was
const T& a
instead ofT a
,the implicit expression variations would make it as if
-std::move(a)
,-b
, and-std::move(b)
were also required with the same semantics,
where
b
is declaredT b
orT& b
.f84ed8f
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.
Please let me know if a444c53 is what you meant.
f84ed8f
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.
Yeah, that looks better.