Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <utility>
- #include <iostream>
- /* forwarded-to fn */
- void f1(int& a) {
- std::cout << "forwarded to f1(int& a): " << a << std::endl;
- }
- /* forwarded-to fn */
- void f1(int&& a) {
- std::cout << "forwarded to f1(int&& a): " << a << std::endl;
- }
- /* forwarding fn template */
- template<class T>
- void f0(T&& input) {
- std::cout << "f0() forwarding " << input << std::endl;
- f1(std::forward<T>(input));
- }
- int main()
- {
- std::cout << "=== A section ===" << std::endl;
- int a = 55;
- f0(5);
- f0(a);
- std::cout << std::endl;
- std::cout << "=== B section ===" << std::endl;
- int b = 10;
- auto&& b1 = b;
- auto&& b2 = 11;
- f0(b1);
- f0(b2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement