compare struct with string member is wield;
Cheng Wei
rivercheng at gmail.com
Tue Oct 11 23:07:38 PDT 2011
Sorry. The previous is not the one causes the problem.
Try this:
struct S {
string str = "Hello"; // Adding an initial value here.
};
S g_s;
unittest {
S s1;
S s2;
assert(s1 == s2); // Success
assert(g_s == s1); // Fail
auto s3 = g_s;
assert(s3 == g_s);; // Even this will fail.
}
It seems if the string is initialized with a default value, then this
does not work.
More information about the Digitalmars-d-learn
mailing list