How should I return multiple const values from a function?
Salih Dincer
salihdb at hotmail.com
Tue Jan 3 07:56:31 UTC 2023
On Tuesday, 3 January 2023 at 07:41:46 UTC, Salih Dincer wrote:
> P.S. Actually the code works when we don't use enum.
My mistake, I forgot that enum cannot be inferred!
Very very sorry, suppose I didn't intervene 😀 Also this has
worked:
```d
void main() {
template Fun(Key, Value)
{
import std.typecons;
alias Tup = Tuple!(const(Key), const(Value));
enum Fun = (Key k, Value v) => Tup(k, v);
}
string k;
uint v;
auto res = Fun!(string, uint)(k, v);
assert(
is(typeof(res[0]) == const(string)) &&
is(typeof(res[1]) == const(uint))
);
}
```
SDB at 79
More information about the Digitalmars-d-learn
mailing list