Inout unclearness
Max Klimov via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jul 24 19:19:39 PDT 2015
On Wednesday, 22 July 2015 at 07:49:07 UTC, Kagamin wrote:
>That's unsafe. Unsafe behavior should require a cast or
>something like that.
Where is unsafety? Code is the same for 3 versions, it guarantees
immutability of data because it was checked for const(T) and
immutable(T).
> How about this?
>
> const(A) f(const(B) b);
> auto constBack(R,P)(const R r, P p);
>
> Then invoke:
>
> B b;
> A a = f(b).constBack(b);
>
> So `f` takes const parameters and returns const result, you
> feed the result to the function `constBack` with one of
> parameters and it infers constness from that parameter and
> casts the result to the inferred constness.
Sorry, I didn't quite get it. What is this example for?
More information about the Digitalmars-d
mailing list