-
Notifications
You must be signed in to change notification settings - Fork 793
[const.wrap.class] Add exposition only for exposition only ctor #8217
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
No, this edit seems wrong. You're looking at a constructor of an exposition-only type, and it feels redundant to add To be fair, the style is inconsistent in another way: @jwakely thoughts? |
In
It does not matter. Whether it is public or not, exposition-only means it does not exist. There are some public functions are also exposition-only, such as |
Looks like that we should introduce a way to specifying that only the name of the member, but not any other aspect, is exposition-only. |
This isn't quite correct. "Exposition-only" means that it doesn't exist in the that exact form, but its effect must be specified (in some degree), per [objects.within.classes]/3. It might be a defect that [objects.within.classes] doesn't seem to cover non-private exposition-only members. I'm quite sure that it's currently required that the following program is well-formed (Godbolt link): #include <type_traits>
template<class>
struct ExtractCW {};
template<auto V, class T>
struct ExtractCW<std::constant_wrapper<V, T>> {
using type = decltype(V);
};
template<auto V>
using ExtractedCWFixedValue = ExtractCW<std::remove_cvref_t<decltype(std::cw<V>)>>::type;
int main() {
ExtractedCWFixedValue<1> x = 1;
} If we change the constructors to be exposition-only, either it would be unspecified whether this program is well-formed, or it would be required that this program is ill-formed. Maybe it's unintended to precisely specify |
That doesn't seem to be the intention. |
It certainly does matter, because if it was shown as a private member it would make the type non-structural, and it couldn't be used as a template parameter, and |
I agree the edit is wrong, but not because it's redundant. There needs to be a way for the compiler to construct this type from a value, and we need to be able to specify that the data member is initialized to the value of the initializer. Guaranteeing that this constructor is present makes that work, so I think the name of the type, and the name of the
Because the types are frequently accessible to users, e.g. the exposition-only Even if we ignore reflection, for #include <type_traits>
template<class> struct Silly;
template<auto Val, class X>
struct Silly<std::constant_wrapper<Val, X>> {
using type = decltype(Val)::type;
auto f() { return Val.data; }
}; Making They can construct values of the type, as JA showed above, but I'm not sure we can do much about that (without heroics that I think would be unnecessary complexity). |
These two constructors should also be exposition-only, so it makes sense to add exposition-only for them?