How does std::forward work? [duplicate]
First, let’s take a look at what std::forward does according to the standard: §20.2.3 [forward] p2 Returns: static_cast<T&&>(t) (Where T is the explicitly specified template parameter and t is the passed argument.) Now remember the reference collapsing rules: (Shamelessly stolen from this answer.) And then let’s take a look at a class that wants to employ perfect forwarding: And now an example invocation: … Read more