Tech Off Post

Single Post Permalink

View Thread: A moving question
  • Norville​Shaggy

    This function use forward:

    Should it not use move instead?

    I used forward in one of my classes, that also caused a copy so i switch to move which did the desired action.

    Can somebody explain why the code doesn't do the right thing?


        template<class _Other1,
            class _Other2>
            pair(pair<_Other1, _Other2>&& _Right,
                typename enable_if<is_convertible<_Other1, _Ty1>::value
                    && is_convertible<_Other2, _Ty2>::value,
                    void>::type ** = 0)
            : first(_STD forward<_Other1>(_Right.first)),
                second(_STD forward<_Other2>(_Right.second))
            {    // construct from moved compatible pair
            }