Created
November 7, 2016 03:22
-
-
Save ak9999/2e1a37bbd4a678aef0df15a03d07c09d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Author: Abdullah Khan | |
Purpose: Show off C++14 automatic return type deduction. | |
Build: g++ -std=c++14 automatic_return_type_deduction.cpp -o create_pair | |
Run: Invoke create_pair with two parameters: words or numbers work best. | |
*/ | |
#include <iostream> | |
#include <utility> | |
using namespace std; | |
template <typename T> | |
auto GetPair(T x, T y) { return make_pair(x,y); } | |
int main(int argc, char ** argv) | |
{ | |
if (argc != 3) return 0; | |
auto p = GetPair(argv[1], argv[2]); | |
cout << "Pair: " << "(" << p.first << " , " << p.second << ")" << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment