Cannot understand some codes in std.concurrency.

ChengWei rivercheng at gmail.com
Wed Sep 14 00:28:10 PDT 2011


In concurrency.d (version 2.055, line 1247 - 1250) , there's some codes
related to internal implementation of List(T).

"
 Range opSlice()
        {
            return Range( cast(Node*) &m_first );
        }
"

What does this mean? m_first itself is Node *, then &m_first is Node **,
then we cast it back to (Node *)? Does it make sense?

If we change "&m_first" to "m_first", it still is weird, because in line
1169:
"
 @property bool empty() const
            {
                return !m_prev.next;
            }
"

The list is empty when m_first is null, that is m_prev is null, not
m_prev.next is null.

Is my understanding of these codes completely wrong, or it is a bug in the
code?

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20110914/f392e25a/attachment.html>


More information about the Digitalmars-d-learn mailing list