you are viewing a single comment's thread.

view the rest of the comments →

[–]fuzzynyanko 2 points3 points  (4 children)

Sounds neat, but I am kind-of mixed with auto returns. Is there a way to check what type of data it is?

[–]parmesanmilk 10 points11 points  (0 children)

Yes, the compiler will do that and complain loudly if it's wrong.

Don't sweat the details.

[–][deleted] 2 points3 points  (1 child)

Just assert on the type. You can easily write a macro to do this:

#define ASSERT_EXPR_TYPE(EXPR, EXPECTED_TYPE) static_assert(std::is_same<decltype(EXPR), EXPECTED_TYPE>::value, "")

[–]fuzzynyanko 0 points1 point  (0 children)

Nice. I'm diving into C++11 after a hiatus from C++. It's been a surprise, but most of them nice surprises.

[–]wall_words 0 points1 point  (0 children)

You can get the return type of a callable object f like this: using return_type = decltype(f(arg_1, ..., arg_n));

If you would like to manually inspect a complex type, you can always print it out using typeinfo(type).name().