
On 2 February 2013 10:27, Nathan Crookston <nathan.crookston@gmail.com>wrote:
http://boost.2283326.n4.nabble.com/is-range-metafunction-td2650470.html
http://boost.2283326.n4.nabble.com/range-Trying-to-make-an-quot-is-range-quo...
It seems most have concluded it's not possible in the general case. I think you could get close enough to count, however. I'd be interested to see the code, myself.
Here it is (C++11): namespace detail { template<typename T> class is_iterable { template<typename U, typename = decltype(std::begin(std::declval<U>()))> static std::true_type has_begin(int); template<typename> static std::false_type has_begin(...); template<typename U, typename = decltype(std::end(std::declval<U>()))> static std::true_type has_end(int); template<typename> static std::false_type has_end(...); typedef decltype(has_begin<T>(0)) has_begin_type; typedef decltype(has_end<T>(0)) has_end_type; public: typedef std::integral_constant<bool, has_begin_type() && has_end_type()> type; }; } // detail namespace template<typename T> struct is_iterable : detail::is_iterable<T>::type {}; I don't know how well it handles namespace issues, though. -- Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404