Skip to content

Instantly share code, notes, and snippets.

@joelreymont
Created June 25, 2012 11:24
Show Gist options
  • Save joelreymont/2988045 to your computer and use it in GitHub Desktop.
Save joelreymont/2988045 to your computer and use it in GitHub Desktop.
// xcrun clang++ -std=c++11 -stdlib=libc++
#include <tuple>
#include <iostream>
using namespace std;
tuple<int, int> minmax(int x, int y)
{
if (x <= y)
return { x, y}
else
return { y, x };
}
int main(int argc, char* argv[])
{
int a, b;
tie(a, b) = minmax(10, 20);
cout << "a = " << a << ", b = " << b << endl;
return 0;
}
biggie:tmp joelr$ xcrun clang++ -std=c++11 -stdlib=libc++ foo.cpp
foo.cpp:11:12: error: chosen constructor is explicit in copy-initialization
return { x, y}
^~~~~~~
/Applications/Xcode45-DP1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/tuple:569:9: note:
constructor declared here
tuple(_Up&&... __u)
^
foo.cpp:13:12: error: chosen constructor is explicit in copy-initialization
return { y, x };
^~~~~~~~
/Applications/Xcode45-DP1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/tuple:569:9: note:
constructor declared here
tuple(_Up&&... __u)
^
2 errors generated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment