Generic programming ramifications of const by default

Georg Wrede georg at nospam.org
Tue Jun 12 10:56:56 PDT 2007


BCS wrote:
> Reply to Georg,
> 
>> I think parameter passing is a world separate from "other const or
>> const-as-default" areas. Thus, having parameters behave differently
>> from them poses no risk for confusion, and, IMHO, is a conceptually
>> clean and intuitive choice. It also has a crystal clear perimeter,
>> which dramatically reduces the mental strain of having to remember
>> things.
> 
> The issue is that a and b in this code are of different types if T is a 
> reference type and that same type otherwise.
> 
> |void TFn(T)(T a)
> |{
> |  T b;
> |}

(Disclaimer: I've been out of town some, so I might have missed 
something important relating to this.)

Within the function (prototype or not), T a would be a read-only 
variable and T b would be the correspoinding read/write variable.

Could you give me an example where this does pose a problem?



More information about the Digitalmars-d mailing list