C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Floating idea: grouping common function qualifiers to reduce syntactic repetition

From: Sebastian Wittmeier <wittmeier_at_[hidden]>
Date: Fri, 22 May 2026 11:03:57 +0200
Perhaps another avenue to get this feature without double the changes is metaclasses (Reflection).   They would enable classes with automatic getters/setters (for those who want them), or serialization or ensuring regularity (rule-of-#) or new defaults (like constexpr).   Then a function qualifier could be made a default for all members of a class.   -----Ursprüngliche Nachricht----- Von:Jens Maurer via Std-Proposals <std-proposals_at_[hidden]> Gesendet:Fr 22.05.2026 10:30 Betreff:Re: [std-proposals] Floating idea: grouping common function qualifiers to reduce syntactic repetition An:std-proposals_at_[hidden]; CC:Jens Maurer <jens.maurer_at_[hidden]>; On 5/22/26 10:20, Daniel Petrovic via Std-Proposals wrote: > *Open questions / concerns* > >   * Which qualifiers would be eligible? (|const|, |noexcept|, |constexpr|, |virtual|, others?) >   * Interaction with overrides, ref-qualifiers, attributes, and trailing requires-clauses >   * >     Parsing complexity Not really.  These are all keywords; this should be designed not to cause another "most vexing parse" situation. >   * Whether this meaningfully improves clarity compared to existing verbosity >   * Risk of hiding important semantics “far away” from the function declaration > > *Prior art / comparison* > This idea is conceptually similar to: > >   * >     Access specifier blocks (|public:|, |private: or Qt signals:, slots:|) >   * Attribute grouping in some other languages >   * Namespace-level defaults or pragmas I can see this to be useful for "constexpr" ("look, this entire class is constexpr-compatible"). For the other qualifiers, there is either a common code style recommendation not to use them excessively (noexcept) or a meaningful variation within a class where a scope-like grouping doesn't seem to be desirable (const, virtual). Is there an opt-out planned?  ("all member functions in this class are constexpr, except this one") You could gather some indication of usefulness by checking how existing code would benefit.  Start with the standard library. I think you'll find plenty of examples for "constexpr an entire class", but zero examples for the other keywords. Jens -- Std-Proposals mailing list Std-Proposals_at_[hidden] https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2026-05-22 09:06:39