How to port C++ std::is_reference<T> to D ?
Q. Schroll
qs.il.paperinik at gmail.com
Wed May 6 17:46:28 UTC 2020
On Wednesday, 6 May 2020 at 09:07:22 UTC, wjoe wrote:
> Hello,
>
> I'm choking on a piece of C++ I have no idea about how to
> translate to D.
>
> std::is_reference<T>
In general, you can't. In D, `ref` is not part of the type, it's
a "storage class", and as such it is a property that a function
parameter can have alongside its type. I.e. in C++, it makes
sense to ask: "Is that parameter's type a reference type?" But in
D it doesn't; you could ask: "Is the parameter given by
reference?" ("Does the parameter have the storage class `ref` [or
`out` to be complete]?")
C++'s decision to make references part of the type has some
advantages, but D didn't do it because of many disadvantages.
More information about the Digitalmars-d-learn
mailing list