Thread overview | |||||
---|---|---|---|---|---|
|
June 25, 2011 Breaking the type system needs temporary? | ||||
---|---|---|---|---|
| ||||
I'm calling functions using ParameterTypeTuple. The problem arise when the parameters is defined as const/immutable. So I need to break out of the type system. But I cannot seem to do this without using a temporary variable. Am I doing something wrong? int i = 1; const(int*) c; //c = &v; // ok - cannot modify const int* cp = cast(int*)c; cp = &v; // ok - breaking type system //(cast(int*)c) = &v; // cannot modify const - shouldn't this work as above? |
June 25, 2011 Re: Breaking the type system needs temporary? | ||||
---|---|---|---|---|
| ||||
Posted in reply to simendsjo | The result of a cast is not an lvalue.
David
On 6/25/11 7:37 PM, simendsjo wrote:
> I'm calling functions using ParameterTypeTuple. The problem arise when
> the parameters is defined as const/immutable. So I need to break out of
> the type system.
> But I cannot seem to do this without using a temporary variable. Am I
> doing something wrong?
>
> int i = 1;
> const(int*) c;
> //c = &v; // ok - cannot modify const
> int* cp = cast(int*)c;
> cp = &v; // ok - breaking type system
> //(cast(int*)c) = &v; // cannot modify const - shouldn't this work as
> above?
|
June 25, 2011 Re: Breaking the type system needs temporary? | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Nadlinger | On 25.06.2011 19:44, David Nadlinger wrote:
> The result of a cast is not an lvalue.
>
> David
>
>
> On 6/25/11 7:37 PM, simendsjo wrote:
>> I'm calling functions using ParameterTypeTuple. The problem arise when
>> the parameters is defined as const/immutable. So I need to break out of
>> the type system.
>> But I cannot seem to do this without using a temporary variable. Am I
>> doing something wrong?
>>
>> int i = 1;
>> const(int*) c;
>> //c = &v; // ok - cannot modify const
>> int* cp = cast(int*)c;
>> cp = &v; // ok - breaking type system
>> //(cast(int*)c) = &v; // cannot modify const - shouldn't this work as
>> above?
>
So the error message is "wrong"? The error message be something like "(cast(int*)c) is not an lvalue"?
|
Copyright © 1999-2021 by the D Language Foundation