
Hi all, In preparation for BoostCon, I'm looking for a workaround for the problems described in http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2855.html. In particular I need a way to detect whether a type "has a move constructor" (without causing a compiler error, of course) in GCC 4.4. Ideally, "has a move constructor" would mean - when constructed from an rvalue of the same type, a copy constructor with signature T(T const&) is not used. though I would settle for - has a constructor with the signature T(T&&) I'm willing to use G++-specific hackery if necessary. I strongly suspect it's impossible, but if you can think of any way to do it, I'd really appreciate knowing about it. You'll be my hero forever ;-) TIA, -- Dave Abrahams BoostPro Computing http://www.boostpro.com

David Abrahams wrote:
I need a way to detect whether a type "has a move constructor" (without causing a compiler error, of course) in GCC 4.4.
What about creating a type U that inherits from T, does using T::T, and deletes U(const U&). Now you just have to check whether U(make<U>()) is a valid expression using SFINAE for expressions.

on Thu Apr 30 2009, Mathias Gaunard <mathias.gaunard-AT-ens-lyon.org> wrote:
David Abrahams wrote:
I need a way to detect whether a type "has a move constructor" (without causing a compiler error, of course) in GCC 4.4.
What about creating a type U that inherits from T, does using T::T, and deletes U(const U&). Now you just have to check whether U(make<U>()) is a valid expression using SFINAE for expressions.
Looks promising, but http://gcc.gnu.org/gcc-4.4/cxx0x_status.html indicates there's no constructor inheritance yet, which I believe is required for that using declaration. That's confirmed by my test with g++-4.4 as available from macports. Trying again with macports/gcc-4.5 prerelease, just for fun. -- Dave Abrahams BoostPro Computing http://www.boostpro.com

On 30.04.2009, at 17:50, David Abrahams wrote:
Ideally, "has a move constructor" would mean
- when constructed from an rvalue of the same type, a copy constructor with signature T(T const&) is not used.
though I would settle for
- has a constructor with the signature T(T&&)
I'm willing to use G++-specific hackery if necessary.
I strongly suspect it's impossible, but if you can think of any way to do it, I'd really appreciate knowing about it. You'll be my hero forever ;-)
While I realize it might be too late for your needs (BoostCon) and what I have is incomplete, I still hope the following is useful as a starting point towards a real has_move_constructor: Tested with GCC 4.4.0 Regards, Daniel
participants (3)
-
Daniel Frey
-
David Abrahams
-
Mathias Gaunard