Created
September 10, 2018 14:19
-
-
Save tamaroth/f5fe9a8c74170fb48a512f86f015c16f to your computer and use it in GitHub Desktop.
Is type iterable trait.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace detail { | |
template<typename T> | |
auto is_iterable_impl(int) -> decltype( | |
std::begin(std::declval<T&>()) != std::end(std::declval<T&>()), | |
++std::declval<decltype(std::begin(std::declval<T&>()))&>(), | |
void(*std::begin(std::declval<T&>())), | |
std::true_type{} | |
); | |
template <typename T> | |
std::false_type is_iterable_impl(...); | |
} | |
/// | |
/// Is the given type iterable? | |
/// | |
template<typename T> | |
using is_iterable = decltype(detail::is_iterable_impl<T>(0)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment