http://d.puremagic.com/issues/show_bug.cgi?id=4500
Max Samukha <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #2 from Max Samukha <[email protected]> 2010-07-26 01:59:01 PDT --- I didn't know D structs were allowed to be moved without calling the copy constructor. Is it really the case? FWIW, modern C++ implementations would optimize the copy out. For example, the following C++ test passes with a recent GNU C++: template <typename T> class Scoped { char data[sizeof(T)]; public: T* payload() { return reinterpret_cast<T*>(data); } Scoped(int i) { new(payload()) T(i); } ~Scoped() { payload()->~T(); } }; template <typename T> Scoped<T> scoped(int i) { Scoped<T> s(i); return s; } class A { public: A() { a = this; } A(int i) { a = this; } A *a; void check() { std::cout << (this == a ? "true" : "false") << std::endl; } ~A() { std::cout << "~A dtor" << std::endl; } }; int main(int argc, char *argv[]) { Scoped<A> a2 = scoped<A>(1); a2.payload()->check(); // ok } Anyway, it is not reasonable to base a fundamental feature like 'scoped' on RVO without having the latter in the language specification. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
