[phobos] phobos commit, revision 2181

Shin Fujishiro rsinfu at gmail.com
Thu Nov 18 14:23:37 PST 2010


By the way, is it acceptable to swap structs that have const member(s)?
std.algorithm.swap() used to allow the following code:
----------
struct S
{
    const string name;
}
auto a = S("a");
auto b = S("b");

swap(a, b);
assert(a.name == "b";
assert(b.name == "a");
----------

This behavior breaks const correctness, whereas it's sometimes useful
since S doesn't allow built-in assignment.  Should swap() disallow it?


Shin


More information about the phobos mailing list