All challenges
Code AnalysisIntermediate 60s

Missing std::forward loses value category

Why does this wrapper copy instead of moving when given an rvalue?
Starter code
#include <utility>

struct Widget { Widget(Widget&&); Widget(const Widget&); };

template <class T>
void relay(T&& arg) {
    Widget w(arg);   // arg is an lvalue expression here
}

Think you can answer under pressure?

Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.

Play this in a 3-minute battle