Open jensmaurer opened 5 years ago
LEWG in Kona: Assume that users have not given types in namespace std access to non-public members of their types unless otherwise permitted by the standard.
(Change “private” to “non-public”). Forward to LWG to update SD-8. SF F N A SA 8 8 1 0 0
P1339R1 Disallowing the friending of names in namespace std (CJ Johnson)
This can be updated post-Cologne; since it doesn't affect the standard directly.
Per chair discussion since this is LEWG policy paper LWG will not review further.
Was reviewed on LEWG mailing list. Attaching a summary of the feedback for this proposal:
Generally good reaction to the direction (the example of friending "make_shared"was brought up). There was a suggestion of an alternative phrasing: To make friending names in std:: useless by making it clear that any invocation described in a component's effects aren't necessarily done as that component, but may be done by some delegated component.
A discussion about SD-8 (https://isocpp.org/std/standing-documents/sd-8-standard-library-compatibility) vs. the standard as the platform:
For in standard:
Examples given for existing restrictions: https://eel.is/c++draft/namespace.std#6, https://eel.is/c++draft/algorithms.requirements#15
For in SD-8:
Discussion regarding whether the result of such use should be UB
Example by Nevin:
class A {
size_t do_hash() const;
friend class std::hash<A>;
template<typename T>
friend class std::hash;
};
namespace std {
template <>
struct hash<A> {
size_t operator()(A const& a) const { return a.do_hash(); }
};
};
To conclude: This topic, as it reveals a major discussion of "indicating the correct usage to users", should be scheduled to an LEWG Telecon.
Deferred to C++26 due to lack of time.
Deferring as we lack a champion for this.
Marking as needs-revision as this is out of date.
P1339R0 Disallowing the friending of names in namespace std (CJ Johnson)