This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH to implement explicit conversion operators
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>, Benjamin Kosnik <bkoz at redhat dot com>
- Date: Mon, 18 May 2009 17:53:36 -0400
- Subject: C++ PATCH to implement explicit conversion operators
I thought this was going to be simpler than it turned out to be.
Allowing explicit on conversion ops and then checking the flag on them
wasn't enough, because we were only handling LOOKUP_ONLYCONVERTING
properly in cases where we are calling a constructor directly.
Extending this to support direct-initialization using explicit
conversion ops required me to add a flags parm to a bunch more
functions, and choose whether or not to set LOOKUP_ONLYCONVERTING at the
point where we ask for the conversion rather than lower down.
After I got this working, I noticed that explicit conversion ops to
class type were still broken; this turns out to be a bug in the
specification which will need to be fixed before C++0x is ready. For
the moment I've worked around this by treating all conversions for the
first parameter of a copy constructor as direct-initialization; look for
the word "hack" in the patch.
Tested x86_64-pc-linux-gnu, applied to trunk.