#include <iostream>
#include <type_traits>
#include <vector>
namespace detail
{
// To allow ADL with custom begin/end
using std::begin;
using std::end;
template <typename T>
auto is_iterable_impl(int)
-> decltype (
begin(std::declval<T&>()) != end(std::declval<T&>()), // begin/end and operator !=
++std::declval<decltype(begin(std::declval<T&>()))&>(), // operator ++
*begin(std::declval<T&>()), // operator*
std::true_type{});
template <typename T>
std::false_type is_iterable_impl(...);
}
template <typename T>
using is_iterable = decltype(detail::is_iterable_impl<T>(0));
static_assert(is_iterable<std::vector<int>>::value, "");
static_assert(is_iterable<int[42]>::value, "");
static_assert(!is_iterable<int>::value, "");
int main()
{
std::cout << is_iterable<std::vector<int>>::value << std::endl;
std::cout << is_iterable<int[42]>::value << std::endl;
std::cout << is_iterable<int>::value << std::endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dHlwZV90cmFpdHM+CiNpbmNsdWRlIDx2ZWN0b3I+CgpuYW1lc3BhY2UgZGV0YWlsCnsKICAgIC8vIFRvIGFsbG93IEFETCB3aXRoIGN1c3RvbSBiZWdpbi9lbmQKICAgIHVzaW5nIHN0ZDo6YmVnaW47CiAgICB1c2luZyBzdGQ6OmVuZDsKCiAgICB0ZW1wbGF0ZSA8dHlwZW5hbWUgVD4KICAgIGF1dG8gaXNfaXRlcmFibGVfaW1wbChpbnQpCiAgICAtPiBkZWNsdHlwZSAoCiAgICAgICAgYmVnaW4oc3RkOjpkZWNsdmFsPFQmPigpKSAhPSBlbmQoc3RkOjpkZWNsdmFsPFQmPigpKSwgLy8gYmVnaW4vZW5kIGFuZCBvcGVyYXRvciAhPQogICAgICAgICsrc3RkOjpkZWNsdmFsPGRlY2x0eXBlKGJlZ2luKHN0ZDo6ZGVjbHZhbDxUJj4oKSkpJj4oKSwgLy8gb3BlcmF0b3IgKysKICAgICAgICAqYmVnaW4oc3RkOjpkZWNsdmFsPFQmPigpKSwgLy8gb3BlcmF0b3IqCiAgICAgICAgc3RkOjp0cnVlX3R5cGV7fSk7Cg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