Last active
August 22, 2018 13:11
-
-
Save mkmkme/d5b1529bb03c5cce3b8fbdeae3d0229d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
[ecko@work cpp]$ cat autohell.cpp | |
#include <iostream> | |
auto add(auto x, auto y) | |
{ | |
return x + y; | |
} | |
struct pt { | |
float _x, _y; | |
pt(float x, float y) : _x(x), _y(y) {} | |
pt operator+(const pt& v) const { return pt(_x + v._x, _y + v._y); } | |
}; | |
std::ostream& operator<<(std::ostream& os, const pt& v) | |
{ | |
os << "pt(" << v._x << ',' << v._y << ')'; | |
return os; | |
} | |
int main() | |
{ | |
std::cout | |
<< add(5,2) << ' ' | |
<< add(5.0, 3.4) << ' ' | |
<< add(pt(1,2), pt(3,4)) << std::endl; | |
return 0; | |
} | |
[ecko@work cpp]$ ninja autohell && ./autohell | |
[1/1] CXXLD autohell | |
autohell.cpp:3:10: warning: use of ‘auto’ in parameter declaration only available with -fconcepts | |
auto add(auto x, auto y) | |
^~~~ | |
autohell.cpp:3:18: warning: use of ‘auto’ in parameter declaration only available with -fconcepts | |
auto add(auto x, auto y) | |
^~~~ | |
7 8.4 pt(4,6) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment