<p><br>
> To make a type "double linkable" the developer needs to mixin the following mixin template:<br>
><br>
>> mixin template DoubleLinkable()<br>
>> {<br>
>>   typeof(this) next;<br>
>>   typeof(this) prev;<br>
>> }<br>
><br>
><br>
> The next and prev pointer can be access with the help of mixin by using the following templates:<br>
><br>
>> T* next(T, string name)(T node) pure nothrow const <br>
>><br>
>> { <br>
>><br>
>>   mixin("return &(node." ~ name ~ ".next);"); <br>
>><br>
>> } </p>
<p>These are free functions? Why not put them in the mixin templates?<br></p>
<p>> To use the above abstraction the developer just needs to do the following:<br>
><br>
>> class Person<br>
>> {<br>
>>   int age;<br>
>>   int weight;<br>
>>   mixin DoubleLinkable people;<br>
>> } </p>
<p>Oh, named mixins! Yet another D feature I totally forgot. Hey, those reading this, who here knew you could do 'mixin someTemplate someName;' to refer to the template scope by the given name?<br></p>
<p>> I am not a big fan of the template signature 'class DoubleLinkedList(T, string name)' but I couldn't figure out a better way of allowing one object to be embedded in multiple containers. Thoughts? Any idea how this can be improved so that it is easier to use and read?</p>

<p>I didn't read the blog post, but any reason why you do not put all the list machinery in a mixin template and refer directly to next/prev?</p>
<p>I'm on a pad, so typing is not so easy, but like this:</p>
<p>mixin template NodeImplementation()<br>
{<br>
    // should detect if typeof(this) is a reference type or a value type.<br>
    // for a reference type, we should not use pointers.<br>
    typeof(this) next() @property { return *_next;}<br>
    typeof(this) prev() @property { return *_prev;}<br>
/// + setters also<br>
    private *typeof(this) _next,_prev;<br>
}</p>
<p>struct Person()<br>
{<br>
    mixin NodeImplementation;<br>
    string name;<br>
    int age;<br>
}</p>
<p>And DoublyLinkedList(Node) if (isNode!Node)</p>
<p>with</p>
<p>/** <br>
A node is a type T that has .next and .prev fields<br>
that return another T. <br>
*/ <br>
isNode(T)<br>
{<br>
    enum isNode = __traits(compiles, { T p = T.init.prev; T n = T.init.next;});<br>
}</p>
<p>   </p>