What can I use instead of std :: move ()?

I am using a C ++ compiler with the C ++ 0x specification and want to make my move constructor for the String class that wraps around std :: wstring.

class String {
public:
    String(String&& str) : mData(std::move(str.mData)) {
    }

private:
    std::wstring mData;
};

In Visual Studio, this works flawlessly. In Xcode is std::move()not available.

+3
source share
1 answer

std::movejust passes its argument to the rvalue link. You can write your own version:

template<class T>
typename std::remove_reference<T>::type&&
move( T&& arg ) noexcept
{
  return static_cast<typename std::remove_reference<T>::type&&>( arg );
}
+4
source

All Articles