eating inout dogfood
Steven Schveighoffer
schveiguy at yahoo.com
Fri Oct 14 13:05:09 PDT 2011
On Fri, 14 Oct 2011 14:17:09 -0400, Walter Bright
<newshound2 at digitalmars.com> wrote:
> On 10/14/2011 4:29 AM, Steven Schveighoffer wrote:
>> On Fri, 14 Oct 2011 04:43:15 -0400, Kagamin <spam at here.lot> wrote:
>>
>>> Steven Schveighoffer Wrote:
>>>
>>>> struct cursor(T)
>>>> {
>>>> T* node;
>>>> void popFront() {node++;}
>>>> ... // usual suspects front, empty, etc
>>>> }
>>>>
>>>> This seems like cursor!(inout(V)) might work (V is the element type
>>>> of the
>>>> container) as the return type for inout functions. However, one of the
>>>> major requirements of inout is that it correctly cast back to the
>>>> constancy of the container.
>>>
>>> try to return inout(cursor!(Unqual!(V)))
>>
>> This won't solve the problem. I need inout to be on V, not on the
>> cursor.
>
> return cursor!(Unqual!(inout(V));
I don't think the compiler will auto-convert someTemplate!(inout(V)) to
e.g. someTemplate!(const(V)). Does that work? I know that for instance,
I can't do this:
struct S(T)
{
T * x;
}
S!(int) ptr;
S!(const(int)) cptr = ptr;
So I wouldn't expect the compiler to do the above translation either...
-Steve
More information about the Digitalmars-d
mailing list