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?

Reply via email to