Re: How to port C++ std::is_reference to D ?

2020-06-06 Thread Q. Schroll via Digitalmars-d-learn
On Wednesday, 13 May 2020 at 13:36:14 UTC, wjoe wrote: On Monday, 11 May 2020 at 19:08:09 UTC, Q. Schroll wrote: [...] 1. You can have variables ("data members") of reference type in structs. (They work like head-const pointers; if D had head-const or at least head-const pointers, those would

Re: How to port C++ std::is_reference to D ?

2020-05-13 Thread wjoe via Digitalmars-d-learn
On Monday, 11 May 2020 at 19:08:09 UTC, Q. Schroll wrote: [...] 1. You can have variables ("data members") of reference type in structs. (They work like head-const pointers; if D had head-const or at least head-const pointers, those would be practically the same, only that references cannot b

Re: How to port C++ std::is_reference to D ?

2020-05-11 Thread Q. Schroll via Digitalmars-d-learn
On Saturday, 9 May 2020 at 13:44:27 UTC, Per Nordlöw wrote: On Wednesday, 6 May 2020 at 17:46:28 UTC, Q. Schroll wrote: C++'s decision to make references part of the type has some advantages, but D didn't do it because of many disadvantages. Can you outline or give a link describing the advan

Re: How to port C++ std::is_reference to D ?

2020-05-09 Thread Per Nordlöw via Digitalmars-d-learn
On Wednesday, 6 May 2020 at 17:46:28 UTC, Q. Schroll wrote: C++'s decision to make references part of the type has some advantages, but D didn't do it because of many disadvantages. Can you outline or give a link describing the advantages of C++'s vs D's choice in this matter?

Re: How to port C++ std::is_reference to D ?

2020-05-07 Thread wjoe via Digitalmars-d-learn
On Wednesday, 6 May 2020 at 16:01:37 UTC, Paul Backus wrote: On Wednesday, 6 May 2020 at 09:40:47 UTC, wjoe wrote: yes, I did read the spec. I read the language spec on traits as well as std.traits docs as well as searching the internet for a solution since day before yesterday. But I couldn't

Re: How to port C++ std::is_reference to D ?

2020-05-06 Thread Q. Schroll via Digitalmars-d-learn
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 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 paramet

Re: How to port C++ std::is_reference to D ?

2020-05-06 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 6 May 2020 at 09:40:47 UTC, wjoe wrote: yes, I did read the spec. I read the language spec on traits as well as std.traits docs as well as searching the internet for a solution since day before yesterday. But I couldn't bring it together because } else static if (__traits(isRe

Re: How to port C++ std::is_reference to D ?

2020-05-06 Thread drug via Digitalmars-d-learn
06.05.2020 12:07, wjoe пишет: Hello, I'm choking on a piece of C++ I have no idea about how to translate to D.   template     typename std::enable_if< std::is_const::value == true, void>::type* = nullptr>     constexpr const char *modifier() const {     return "[in] ";     }  

How to port C++ std::is_reference to D ?

2020-05-06 Thread wjoe via Digitalmars-d-learn
Hello, I'm choking on a piece of C++ I have no idea about how to translate to D. template typename std::enable_if< std::is_const::value == true, void>::type* = nullptr> constexpr const char *modifier() const { return "[in] "; } template typename std::enab

Re: How to port C++ std::is_reference to D ?

2020-05-06 Thread wjoe via Digitalmars-d-learn
On Wednesday, 6 May 2020 at 09:19:10 UTC, drug wrote: 06.05.2020 12:07, wjoe пишет: Hello, I'm choking on a piece of C++ I have no idea about how to translate to D.   template     typename std::enable_if< std::is_const::value == true, void>::type* = nullptr>     constexpr const char