On Tue, 09 Apr 2013 16:03:01 -0400, Joseph Rushton Wakeling <joseph.wakel...@webdrake.net> wrote:

Any thoughts? :-)

1. documentation. Make sure the user of the range knows that this data is going to be re-used. 2. Make front() return const if possible. It is another signal that you aren't supposed to keep this data.
3. For your specific situation, add lastFront():

struct MySimulation(T)
{
        T[] var;
        T[] lastVar;
        T diff, convergence;

        auto front() @property
        {
                return var;
        }

        bool empty() @property
        {
                return (diff < convergence);
        }

        void popFront()
        {
                lastVar[] = var[];
                // update values in var
                // and calculate diff
        }
        
        auto lastFront() @property
        {
                return lastVar;
        }
}

-Steve

Reply via email to