clang++ c++0x and std::move

I am using clang with xcode 4 along with the -std=c++0x option.

The clang compiler seems to generate an error and say that no matching
parameters can be found for the following move function. However the code
compiles perfectly find on MSVC2010.

int a =10;
void rvalueFunc(std::move(a)); // clang produces an error at this line.

Just in case clang did not implement std::move, I wrote another version
myself too and tested it, but it still gives an error of a non matching

here is the other version of Move that I wrote, which was taken from msvc.
template struct RemoveReference {
     typedef T type;

template struct RemoveReference<T&> {
     typedef T type;

template struct RemoveReference<T&&> {
     typedef T type;

template typename RemoveReference::type&& Move(T&& t) {
    return t;


Do you use libc++ or libstdc++ ? I'm almost sure the default c++ library on OS X (libstdc++) does not support any c++0x feature.

To install and use the libc++ with clang, just follow the instructions at

-- Jean-Daniel

hi, I have tried with both and both libc++ or libstdc++(using my own written
move func) causes clang to emit and error "there is no matching function
call to rvalueFunc()" and "there is no known conversion from int to int&&
for 1st argument".

I am not sure but perhaps the usage of libc++ or libstdc++ wouldn't affect
much, as probably this is related to the interpretation and parsing of
rvalues by the clang compiler.


Er, what's that code supposed to mean?
With a svn snapshot of clang here, move seems to work:

#include <utility>
void rvalueFunc(int&&);
void f(){
   int a =10;

The code is just a simplified version of the code. The actual code is
something of

struct MessageData
     char* message_payload;

           if (message_payload) delete [] message_payload;

void ParseMessage(MessageData&& message) {...};
void ParseMessage(const MessageData& message) {...};

MessageData test;
ParseMessage(std::move(test)); //generates the same error.

I using xcode 4 so I am not sure how I can test with the latest snapshot of
the svn. according to xcode 4 it is using the 2.9 snapshot.


None of the compilers in XCode 4 support C++0x. We recognize the
option, but several majors features do not work, as you've noticed.
There's been a lot of recent work on trunk, if you're interested.