Aug 27, 2014 at 12:07am UTC
http://coliru.stacked-crooked.com/a/3d504a053674f758 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#include <iostream>
auto func()
{
struct Test
{
int f();
};
return Test{};
}
int main()
{
auto t = func();
std::cout << t.f() << std::endl;
}
using func_Test = decltype (func());
int func_Test::f()
{
return 7;
}
To me, this seems really cool. I don't think it's very useful, though.
Last edited on Aug 27, 2014 at 12:10am UTC
Aug 27, 2014 at 12:27am UTC
That's c++14? Interesting.
Aug 27, 2014 at 12:36am UTC
Last edited on Aug 27, 2014 at 12:39am UTC
Aug 27, 2014 at 12:40am UTC
Weird, I have no idea what ideone is using for its C++11 option, I just know it's GCC.
C++14 == C++1y, but C++1z is the standard after it (possibly C++17)
Last edited on Aug 27, 2014 at 12:41am UTC
Aug 27, 2014 at 2:42am UTC
Interesting, the code compiles with GCC 4.8.2 (with -std=c++11), and only gives this warning:
warning: ‘func’ function uses ‘auto’ type specifier without trailing return type [enabled by default]
auto func()
^
Last edited on Aug 27, 2014 at 2:42am UTC
Aug 27, 2014 at 2:47pm UTC
Last edited on Aug 27, 2014 at 2:48pm UTC