Why does templated interface function return something different than final function?

Timoses timosesu at gmail.com
Mon Aug 6 14:27:01 UTC 2018


On Thursday, 2 August 2018 at 20:35:57 UTC, Steven Schveighoffer 
wrote:
>
> Looking at the AST, it appears that toImpl doesn't recognize 
> what inout(iface) is:
>
> toImpl!(string, inout(iface))
> {
> 	@system string toImpl(ref inout(iface) value)
> 	{
> 		import std.array : appender;
> 		import std.format : FormatSpec, formatValue;
> 		Appender!string w = appender();
> 		FormatSpec!char f = FormatSpec;
> 		formatValue(w, value, f);
> 		return w.data();
> 	}
>
> }
>
> Vs. the nice neat call for const(iface)
>
> toImpl!(string, const(iface))
> {
> 	@system string toImpl(const(iface) value)
> 	{
> 		return toStr(value);
> 	}
>
> }
>
> Note the ref there, too. This means it can't cast to const. I 
> wonder if that's an issue.
>
> -Steve

Thanks for the insight. To me it sounds like std.conv `toImpl` 
doesn't properly handle inout types in this case.


More information about the Digitalmars-d-learn mailing list