C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::arithmetic (concept)

From: Sebastian Wittmeier <wittmeier_at_[hidden]>
Date: Fri, 18 Apr 2025 12:17:37 +0200
If there are several existing ways, then they won't go away. Why introduce another one instead of promoting the best of the existing ones? One of the advantage of (some) existing ways is compatability, as they are reusing features.   If you really go into type tagging and make a core language change proposal, then it should bring added benefits. See type traits in other languages. Haskell and Scala are known to be strong there and could be an inspiration.   -----Ursprüngliche Nachricht----- Von:Frederick Virchanza Gotham via Std-Proposals <std-proposals_at_[hidden]> Gesendet:Fr 18.04.2025 11:44 Betreff:Re: [std-proposals] std::arithmetic (concept) An:std-proposals_at_[hidden]; CC:Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>; On Thu, Apr 17, 2025 at 4:54 PM Sebastian Wittmeier wrote: > > The point is that you can tag a class from outside, that you > can choose whether to include derived classes and especially > that no core language change is necessary. Oh so you're arguing that the core language shouldn't be touched unless we're making something possible that was previously impossible. If that's how we're going about standardising C++, then how did structured bindings make it in? They're pointless from the point of view that they didn't make anything possible that wasn't already possible. There is nothing wrong with the following code:    tuple<int, double, char> t = {1, 2.5, 'x'};    auto a = get<0u>(t);    auto b = get<1u>(t);    auto c = get<2u>(t); but somebody who's greedy with their keyboard button presses wanted it changed to:    tuple<int, double, char> t = {1, 2.5, 'x'};    auto [a, b, c] = t; Absolutely pointless but the committee saw fit to pass this parsing burden to compiler vendors. Not quite as bad an atrocity as using '&&' for forwarding references but still I don't know how committee members could look compiler programmers in the eye after this demand. Not to mention confusing lots of programmers who glance at it and think "hmmmmmm that's a funny looking lambda". Tagging a class is already possible in C++, I'm not disputing that. But what is 'standardisation' all about? Well, one thing it's about is: Instead of having 20 people doing something 5 different ways, how about we have 20 people all doing something the same way. So far we've talked about 3 or 4 different ways of tagging a class, and some of these ways of tagging a class are inherited by a derived class. We could standardise this so that everyone's doing it the same way and so it's more explicit and verbose. Plus it would be nice to able to iterate through a classes tags:    class MyClass {        _Tag arithmetic;    };    int main(void)    {        for ( auto &t : typeid(MyClass).tags ) /* Do Something */ ;    } But that would probably be an extension to the 'reflection' papers. -- Std-Proposals mailing list Std-Proposals_at_[hidden] https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2025-04-18 10:23:58