Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AlisdairM
Copy link
Contributor

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

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.
Copy link
Member

@mattkretz mattkretz left a 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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>{};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
constexpr auto cw = constant_wrapper<X>{};
constexpr auto @\libglobal{cw} = constant_wrapper<X>{};

… I think. I'm still new to indexing, myself. 😉

Copy link
Member

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}%
Copy link
Member

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?

Comment on lines +647 to +649
using type = T; // \expos
constexpr @\exposid{cw-fixed-value}@(type v) noexcept: data(v) { }
T data; // \expos
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Member

@jensmaurer jensmaurer Jun 26, 2025

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

Comment on lines +654 to +656
using type = T[Extent]; // \expos
constexpr @\exposid{cw-fixed-value}@(T (&arr)[Extent]) noexcept;
T data[Extent]; // \expos
Copy link
Member

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)>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Comment on lines +828 to +830
struct constant_wrapper: cw-operators {
static constexpr const auto & value = X.data;
using type = constant_wrapper;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Member

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}.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
template<@\exposid{constexpr-param}@ T>
template<@\exposconcept{constexpr-param}@ T>

Forgot this one before. Same for all the other uses of constexpr-param

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.

[2025-06 LWG Motion 32] P2781R9 std::constant_wrapper P2781 R8 std::constexpr_wrapper
3 participants