Taking a constant reference to a constant/non const object

Jonathan M Davis newsgroup.d at jmdavisprog.com
Wed Nov 15 09:23:53 UTC 2017


On Wednesday, November 15, 2017 09:04:50 helxi via Digitalmars-d-learn 
wrote:
> Hi. What function signature should I use for receiving a constant
> reference of an r/l value object? Is it auto fn(inout ref const
> myClass obj)?
> I want to:
> 1. Take a constant reference of the object, not copy them
> 2. The object itself may be const or non const.

ref const(Type) would be the const version of ref Type. e.g.

auto foo(ref const(int) i) {...}

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list