Question Details

No question body available.

Tags

c++ std move

Answers (1)

July 9, 2026 Score: 10 Rep: 129,742 Quality: High Completeness: 80%

The reasons for std::forward are the same as for std::move. Its a common name and it accepts any value. An unqualified call opens the door to ADL.

namespace foo {
    struct foo {};
    template  void forward(foo&) {}
};

int main() { foo::foo f; using std::forward; auto g = forward(f); // calls foo::forward auto h = std::forward(f); }

Neither std::move nor std::forward are sensible customization points. They both are just shorthand for a cast that would be confusing to replace with something else.

One shouldnt write something like foo::forward, but suppose its from a library predating C++11. Or its a recent library and nobody ever noticed it could be an issue (eg. because they are following the recomendation for fully qualified calls to std::forward).

Note that the example is chosen such that a compiler error is produced. If foo::forward had the same signature one can easily overlook that auto g = forward(f) does not call std::forward.

Don't think of using std::forward merely as a way of typing less. Its not just that. It enables ADL. Sometimes thats useful. Not here.