16.47 compile your own version of the flip function and test it by calling the function that accepts the left and right reference parameters.
# Include <iostream> # include <string> # include <utility> using namespace STD; Template <typename T> int compare (const T & A, const T & B) {if (a <B) Return-1; if (B <a) return 1; return 0;} template <typename T> auto sum (t a, t B) -> decltype (a + B) {return a + B;} // flip function template <typename F, typename T1, typename T2> void flip (f, t1 & T1, T2 & T2) {f (STD: Forward <t2> (T2), STD: Forward <t1> (T1 ));} void F (INT V1, Int & V2) {cout <V1 <"" <++ V2 <Endl;} void g (Int & I, int & J) {cout <I <"" <j <Endl ;}int main () {Int J = 8; compare <const char *> ("hi", "world"); flip (F, J, 42); cout <j <Endl; flip (G, J, 42 );}
Forward: some functions need to forward one or more real parameters along with their types to other functions.