d返回多个常量值
原文
想要这样:
bool func (const out Key k, const out Val v) { k = this.key.dup; v = this.val.dup; return true; }
你可以这样:
import std.typecons;
auto func(Key, Value)(Key k, Value v)
{
return Tuple!(const(Key), const(Value))(k, v);
}
void main()
{
string k;
uint v;
auto result = func(k, v);
static assert(is(typeof(result[0]) == const(string)));
static assert(is(typeof(result[1]) == const(uint)));
}
浙公网安备 33010602011771号