C++ Logo

std-proposals

Advanced search

Re: The new new thing

From: connor horman <chorman64_at_[hidden]>
Date: Thu, 20 Feb 2020 20:20:16 -0500
On Thu, Feb 20, 2020 at 20:10 Matt Hurd via Std-Proposals <
std-proposals_at_[hidden]> wrote:

>
>> For integers, we really can do something similar in one line with:
>> enum class qty_t : int64_t {};
>>
> That's a good positive example. Sadly not so sanguine for *double* or
> *complex*.
>
>
>> While we are technically out of luck for other types, a wrapping
>> aggregate struct isn’t that horrible (though potentially with an attribute
>> that hints it wants the abi of the wrapped field).
>>
> I'm not so skilled. I find it a wee bit horrible especially w.r.t.
> constructors.
>
> Still, cloning, and possibly cloning with extensions, seems a useful
> thing. Perhaps too useful though ;-)
>
For aggregates you don’t need to write constructors. For double/other
non-integrals it would be as simple as
struct radians{
   double value;
};

Also, I suppose a question would be how you intended to get the value out
of the “new” types. If by static_cast, I could see the removal of the
boilerplate to get that being a potential positive for your method (though
maybe not enough to justify a core language extension, I don’t know).

I also don’t see why the 2nd example can’t just use inheritance. I would
suppose you would lose standard layout if you wanted to add any fields
using normal inheritance (would this be a problem with cloning).

>
> --Matt.
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2020-02-20 19:23:08