Do not understand why one line is not considered @safe, but the other is.

//----

module test;

import std;

@safe void main()
{
    immutable string[] strings = ["one", "one", "two"];

    immutable(string)*[] pointers = null;

    foreach(size_t i, ref str; strings)
    {
        if(str == "one")
        {
            //pointers ~= &str; // not allowed in @safe ??

pointers ~= &strings[i]; // for @safe, I have to revert to using an index into strings.
        }
        i++;
    }
}

//-----

Reply via email to