[Bug c++/40655] The copy constructor is not needed but GCC (C++) don't let me to initialize my object instance!

MSHojatoleslami at Gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Jul 6 17:20:00 GMT 2009



------- Comment #2 from MSHojatoleslami at Gmail dot com  2009-07-06 17:19 -------
Thanks for your answer.
But there is no need to copy them always as you know:

// ---------- begin
#include <iostream>
class A
{
public :
    A (int i)
    {
        std::cout << "Copy constructor is not used." << std::endl;
    }
};
int main ()
{
    auto a1 = A (5); // Straight Construction
    A a2[3] = { A (0), A (1), A (2) }; // Straight Construction

}
// ---------- end

So, why copy constructor needed to be public, although it's not used!?
Excuse me, If i insist on it. Because i really don't know why it's not a bug,
Specially for "auto" keyword.
There is XFC classes (XFC toolkit that wraps Gtk+) that their copy constructors
are private for some reason, and now, there is no way to use "auto" keyword to
initialize them. Instead, i must to initialize them with the old ways of
standard C++03.


-- 

MSHojatoleslami at Gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40655



More information about the Gcc-bugs mailing list