class Foo
{
Foo f;
Foo bar () const
{
return f;
}
}
The above code results in the compile error:
Error: cannot implicitly convert expression (this.f) of type const(Foo)
to test.Foo
But if I change "bar" to:
Object bar () const
{
return f;
}
I don't get any error
On Sunday, April 15, 2012 17:57:27 Jacob Carlborg wrote:
> class Foo
> {
> Foo f;
>
> Foo bar () const
> {
> return f;
> }
> }
>
> The above code results in the compile error:
>
> Error: cannot implicitly convert expression (this.f) of type const(Foo)
> to test.Foo
>
On 2012-04-16 02:33, Jonathan M Davis wrote:
It definitely looks like a bug. Whether it returns Foo or Object should have no
effect on constness, and since f is a member variable of Foo, and the this
pointer/reference is const, bar is going to have to return a const reference
to it, which the se