Because of the implementation of std::declval<T>(), it's impossible to
find the correct overload for std::begin() if T is an array type. I know
C arrays disobey many of the usual properties of types in C++, but this
seems like something that should Just Work.
template<typename T>
struct iterated {
using type = decltype(*std::begin(std::declval<T>()));
};
using X = typename iterated<std::vector<int>>::type; // OK
using Y = typename iterated<int[2]>::type; // FAILS
If you want to play around with the code, you can go here:
<
http://ideone.com/Jtn7YF>.
Is this something worthy of a fix to the standard? I don't think we
should expect users to write template specializations for arrays just to
make something like this work.
Of course, if there's a better way to create a trait like this, I'd be
happy to hear about it.
- Jim