D 在函数声明中使用带有“auto”返回值的属性
我认为这不需要太多解释。如何在D中获得D 在函数声明中使用带有“auto”返回值的属性,d,D,我认为这不需要太多解释。如何在D中获得h()声明的预期效果?我相信您使用auto本身作为返回类型,并且在函数体中,您使用适当的常量限定符返回一个值。您可以使用cast(const)value语法向值添加const限定符 struct A { auto f(); // fine const(int) g() const; // fine const(auto) h() const; // *death* inout(auto) h() inout; // *deat
h()
声明的预期效果?我相信您使用auto
本身作为返回类型,并且在函数体中,您使用适当的常量限定符返回一个值。您可以使用cast(const)value
语法向值添加const限定符
struct A {
auto f(); // fine
const(int) g() const; // fine
const(auto) h() const; // *death*
inout(auto) h() inout; // *death*
...(auto) h() ...; // etc. etc.
}