std::forward in C++

std::forward in C++

innocentzero

2026-06-14

#cpp #templates | Status: Complete

Most of the article was inspired from this brilliant answer from stackoverflow.

std::forward in C++

Forwarding

Given an expression E(a,b,c,d ...), each of some templated type, we want f(a,b,c,d...) to be equivalent. So nest E inside f.

This cannot be accomplished by C++03.

What std::forward does

This combination is called as perfect forwarding.