Re: Pass enum variable as const ref arg

2020-12-08 Thread Q. Schroll via Digitalmars-d-learn
On Friday, 4 December 2020 at 12:54:25 UTC, Andrey wrote: [...] WTF? If you come from a C or C++ background, it's quite reasonable to think of enum stuff like a #define macro. You're using static arrays, but note that array literals allocate in many use cases. It really is like a C/C++ macro

Re: Pass enum variable as const ref arg

2020-12-04 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 4 December 2020 at 12:54:25 UTC, Andrey wrote: Hello, void test(const ref string[3] qazzz) { qazzz.writeln; } void main() { enum string[3] value = ["qwer", "ggg", "v"]; test(value); } Gives errors: It works if you pass `-preview=rvaluerefparam` to the compiler. But the

Re: Pass enum variable as const ref arg

2020-12-04 Thread Andrey via Digitalmars-d-learn
Thank you!

Re: Pass enum variable as const ref arg

2020-12-04 Thread Paul Backus via Digitalmars-d-learn
On Friday, 4 December 2020 at 13:42:45 UTC, Andrey wrote: Hm, you mean that enum variable is not a real variable? I thought that to make CT variable you should mark it as enum (in c++ as constexpr). How to do it here? The official name for what you're calling an "enum variable" is "manifest

Re: Pass enum variable as const ref arg

2020-12-04 Thread rikki cattermole via Digitalmars-d-learn
On 05/12/2020 2:42 AM, Andrey wrote: Hm, you mean that enum variable is not a real variable? It is not a variable. It is a constant that cannot be changed and does not exist in the executable. I thought that to make CT variable you should mark it as enum (in c++ as constexpr). How to do it

Re: Pass enum variable as const ref arg

2020-12-04 Thread Andrey via Digitalmars-d-learn
Hm, you mean that enum variable is not a real variable? I thought that to make CT variable you should mark it as enum (in c++ as constexpr). How to do it here?

Re: Pass enum variable as const ref arg

2020-12-04 Thread rikki cattermole via Digitalmars-d-learn
On 05/12/2020 1:54 AM, Andrey wrote: Hello, void test(const ref string[3] qazzz) { qazzz.writeln; } void main() {     enum string[3] value = ["qwer", "ggg", "v"]; That is a compile time constant (remove the enum).     test(value); } Gives errors: onlineapp.d(26): Error: function onlinea

Pass enum variable as const ref arg

2020-12-04 Thread Andrey via Digitalmars-d-learn
Hello, void test(const ref string[3] qazzz) { qazzz.writeln; } void main() { enum string[3] value = ["qwer", "ggg", "v"]; test(value); } Gives errors: onlineapp.d(26): Error: function onlineapp.test(ref const(string[3]) qazzz) is not callable using argument types (string[3]) online