ContainerTag.hpp
Go to the documentation of this file.
00001 // ========================================================================================
00002 //  ApproxMVBB
00003 //  Copyright (C) 2014 by Gabriel Nützi <nuetzig (at) imes (d0t) mavt (d0t) ethz (døt) ch>
00004 //
00005 //  This Source Code Form is subject to the terms of the Mozilla Public
00006 //  License, v. 2.0. If a copy of the MPL was not distributed with this
00007 //  file, You can obtain one at http://mozilla.org/MPL/2.0/.
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 


asr_approx_mvbb
Author(s): Gassner Nikolai
autogenerated on Sat Jun 8 2019 20:21:49