-
Notifications
You must be signed in to change notification settings - Fork 777
P2781R9 std::constant_wrapper #8018
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
base: main
Are you sure you want to change the base?
Conversation
Fixes 7969 Fixes cplusplus/papers#1458 Allowed paragraphs to number themselves correctly. For consistency, did not use code font for constexpr in the phrase constexpr function. This revision has many Overfull hboxes that will be addressed next commit.
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'm not an authority on indexing.
Did you forget the changes to [span.syn] and [version.syn] or did I overlook something?
struct constant_wrapper; | ||
|
||
template<class T> | ||
concept @\exposid{constexpr-param}@ = requires { typename constant_wrapper<T::value>; }; // \expos |
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.
concept @\exposid{constexpr-param}@ = requires { typename constant_wrapper<T::value>; }; // \expos | |
concept @\defexposconcept{constexpr-param}@ = requires { typename constant_wrapper<T::value>; }; // \expos |
struct @\exposid{cw-operators}@; // \expos | ||
|
||
template<@\exposid{cw-fixed-value}@ X> | ||
constexpr auto cw = constant_wrapper<X>{}; |
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.
constexpr auto cw = constant_wrapper<X>{}; | |
constexpr auto @\libglobal{cw} = constant_wrapper<X>{}; |
… I think. I'm still new to indexing, myself. 😉
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.
There's a missing @ at the end of libglobal{cw}. Otherwise agreed with the approach.
@@ -624,6 +638,265 @@ | |||
are used as base classes to define | |||
the interface for various type traits. | |||
|
|||
\indexlibrarymember{value_type}{integral_constant}% |
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.
This line seems to be a copy&paste left-over?
using type = T; // \expos | ||
constexpr @\exposid{cw-fixed-value}@(type v) noexcept: data(v) { } | ||
T data; // \expos |
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.
using type = T; // \expos | |
constexpr @\exposid{cw-fixed-value}@(type v) noexcept: data(v) { } | |
T data; // \expos | |
using @\exposid{type}@ = T; // \expos | |
constexpr @\exposid{cw-fixed-value}@(type v) noexcept: data(v) { } | |
T @\exposid{data}@; // \expos |
At least, that's what I recall from review in LWG.
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.
Both are marked with "// \expos", so should use \exposid decoration, yes. (Also all uses of these identifiers.)
using type = T[Extent]; // \expos | ||
constexpr @\exposid{cw-fixed-value}@(T (&arr)[Extent]) noexcept; | ||
T data[Extent]; // \expos |
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.
Likewise.
struct @\exposid{cw-operators}@ { // \expos | ||
// unary operators | ||
template<@\exposid{constexpr-param}@ T> | ||
friend constexpr auto operator+(T) noexcept -> constant_wrapper<(+T::value)> |
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.
friend constexpr auto operator+(T) noexcept -> constant_wrapper<(+T::value)> | |
friend constexpr auto @\libmember{operator+}{constant_wrapper}@(T) noexcept -> constant_wrapper<(+T::value)> |
Same for all the other operators. Though, constant_wrapper
isn't 100% correct, I believe it's what is most helpful even to implementers.
struct constant_wrapper: cw-operators { | ||
static constexpr const auto & value = X.data; | ||
using type = constant_wrapper; |
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.
struct constant_wrapper: cw-operators { | |
static constexpr const auto & value = X.data; | |
using type = constant_wrapper; | |
struct @\libglobal{constant_wrapper}@: cw-operators { | |
static constexpr const auto & @\libmember{value}{constant_wrapper}@ = X.data; | |
using @\libmember{type}{constant_wrapper}@ = constant_wrapper; |
etc.
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.
... and make "data" \exposid, assuming it's the exposition-only thing from earlier.
\begin{itemdescr} | ||
\pnum | ||
\effects | ||
Initialize elements of \tcode{data} with corresponding elements of \tcode{arr}. |
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.
Initialize elements of \tcode{data} with corresponding elements of \tcode{arr}. | |
Initialize elements of \exposid{data} with corresponding elements of \tcode{arr}. |
|
||
struct @\exposid{cw-operators}@ { // \expos | ||
// unary operators | ||
template<@\exposid{constexpr-param}@ T> |
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.
template<@\exposid{constexpr-param}@ T> | |
template<@\exposconcept{constexpr-param}@ T> |
Forgot this one before. Same for all the other uses of constexpr-param
Fixes #7969
Fixes cplusplus/papers#1458
Allowed paragraphs to number themselves correctly.
For consistency, did not use code font for constexpr in the phrase "constexpr function".