Sujet : Re: We have a new standard!
De : sam (at) *nospam* email-scan.com (Sam)
Groupes : comp.lang.c++Date : 08. Jan 2025, 03:32:34
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <cone.1736303554.245883.371457.1000@ripper.email-scan.com>
References : 1 2 3 4 5 6
User-Agent : https://www.courier-mta.org/cone/
Chris Ahlstrom writes:
Muttley@DastardlyHQ.org wrote this post while blinking in Morse code:
>
I never understood the point of that. Why not increase the semantic scope
of "typedef" instead of having 2 keywords that in a lot of circumstances
do the same thing?
>
Because using is a nicer to read?
I was wondering about that, too. I forget the exact keywords I used when searching for the answer, but I did read a convincing argument in favor of a using declaration.
This was not the main argument, but there are some things that can be done with using that cannot be done with a typedef. For example, using a real- life example:
template<typename basedon_t>
using derivedvaluelist=ref<derivedvalueListObj<basedon_t>,
derivedvalueListBase<basedon_t>>;
There is no equivalent typedef declaration, for this.
Given that, here's the main argument: if you originally start out with a using declaration, instead of a typedef:
using derivedvaluelist=ref<derivedvalueListObj, derivedvalueListBase>;
then, at some point later: going from that, to the template, looks more "logical" then replacing a typedef with something else, entirely.
TLDR: the "left" and the "right" side component, of the alias declaration, is consistent, versus swapped.