/* Test user-defined assignment operators, when the class has a copy constructor, and therefore a model of Regular is generated, which uses assignment. */ class foo { foo() : x(0) { } foo(int x) : x(x) { } foo(foo other) : x(other.x) { } int x; }; fun operator=(foo! f, foo g) -> foo! { f.x = g.x; return f; } model Regular { }; model DefaultConstructible { }; fun bar where { Regular, DefaultConstructible } (T x, T! y) { let tmp = @T(); tmp = x; y = tmp; } fun main() -> int@ { let f1 = @foo(2); let f2 = @foo(3); /* Test direct use of assignment */ f2 = f1; let f3 = @foo(4); let f4 = @foo(5); /* Test use of assignment through the Regular concept */ bar(f3, f4); return (f1.x - f2.x) + (f3.x - f4.x); }