Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef ApproxMVBB_Common_ContainerTag_hpp
00011 #define ApproxMVBB_Common_ContainerTag_hpp
00012
00013 #include <type_traits>
00014
00015 namespace ApproxMVBB{
00016 namespace ContainerTags{
00017
00018 namespace details{
00019 inline constexpr auto is_container_impl(...) -> std::false_type {
00020 return std::false_type{};
00021 }
00022
00023 template <typename C>
00024 constexpr auto is_container_impl(C const* c) ->
00025 decltype(begin(*c), end(*c), std::true_type{})
00026 {
00027 return std::true_type{};
00028 }
00029
00030
00031 inline constexpr auto is_associative_container_impl(...)
00032 -> std::false_type
00033 { return std::false_type{}; }
00034
00035 template <typename C, typename = typename C::key_type>
00036 constexpr auto is_associative_container_impl(C const*) -> std::true_type {
00037 return std::true_type{};
00038 }
00039 }
00040
00041
00042 template <typename C>
00043 constexpr auto is_container(C const& c) -> decltype(details::is_container_impl(&c)) {
00044 return details::is_container_impl(&c);
00045 }
00046
00047 template <typename C>
00048 constexpr auto is_associative(C const& c)
00049 -> decltype(details::is_associative_container_impl(&c))
00050 {
00051 return details::is_associative_container_impl(&c);
00052 }
00053
00054 template<typename C>
00055 using IteratorCategoryOf = typename std::iterator_traits<typename C::iterator>::iterator_category;
00056
00057 template<typename C>
00058 using has_randomAccessIterator = std::is_base_of<std::random_access_iterator_tag, IteratorCategoryOf<C> >;
00059
00060 template<typename C>
00061 using has_bidirectionalIterator = std::is_base_of<std::bidirectional_iterator_tag, IteratorCategoryOf<C> >;
00062 }
00063 }
00064
00065 #endif // AssociativeContainer_hpp
00066