Skip to content

Instantly share code, notes, and snippets.

@ak9999
Created November 7, 2016 03:22
Show Gist options
  • Save ak9999/2e1a37bbd4a678aef0df15a03d07c09d to your computer and use it in GitHub Desktop.
Save ak9999/2e1a37bbd4a678aef0df15a03d07c09d to your computer and use it in GitHub Desktop.
/*
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