ContainerTag.hpp
Go to the documentation of this file.
1 // ========================================================================================
2 // ApproxMVBB
3 // Copyright (C) 2014 by Gabriel Nützi <nuetzig (at) imes (d0t) mavt (d0t) ethz (døt) ch>
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 // ========================================================================================
9 
10 #ifndef ApproxMVBB_Common_ContainerTag_hpp
11 #define ApproxMVBB_Common_ContainerTag_hpp
12 
13 #include <type_traits>
14 
15 namespace ApproxMVBB{
16 namespace ContainerTags{
17 
18 namespace details{
19  inline constexpr auto is_container_impl(...) -> std::false_type {
20  return std::false_type{};
21  }
22 
23  template <typename C>
24  constexpr auto is_container_impl(C const* c) ->
25  decltype(begin(*c), end(*c), std::true_type{})
26  {
27  return std::true_type{};
28  }
29 
30 
31  inline constexpr auto is_associative_container_impl(...)
32  -> std::false_type
33  { return std::false_type{}; }
34 
35  template <typename C, typename = typename C::key_type>
36  constexpr auto is_associative_container_impl(C const*) -> std::true_type {
37  return std::true_type{};
38  }
39 }
40 
41 
42  template <typename C>
43  constexpr auto is_container(C const& c) -> decltype(details::is_container_impl(&c)) {
44  return details::is_container_impl(&c);
45  }
46 
47  template <typename C>
48  constexpr auto is_associative(C const& c)
50  {
52  }
53 
54  template<typename C>
55  using IteratorCategoryOf = typename std::iterator_traits<typename C::iterator>::iterator_category;
56 
57  template<typename C>
58  using has_randomAccessIterator = std::is_base_of<std::random_access_iterator_tag, IteratorCategoryOf<C> >;
59 
60  template<typename C>
61  using has_bidirectionalIterator = std::is_base_of<std::bidirectional_iterator_tag, IteratorCategoryOf<C> >;
62 }
63 }
64 
65 #endif // AssociativeContainer_hpp
66 
These are some container definitions.
constexpr auto is_container_impl(...) -> std::false_type
std::is_base_of< std::bidirectional_iterator_tag, IteratorCategoryOf< C > > has_bidirectionalIterator
typename std::iterator_traits< typename C::iterator >::iterator_category IteratorCategoryOf
constexpr auto is_container(C const &c) -> decltype(details::is_container_impl(&c))
constexpr auto is_associative_container_impl(...) -> std::false_type
std::is_base_of< std::random_access_iterator_tag, IteratorCategoryOf< C > > has_randomAccessIterator
constexpr auto is_associative(C const &c) -> decltype(details::is_associative_container_impl(&c))


asr_approx_mvbb
Author(s): Gassner Nikolai
autogenerated on Mon Jun 10 2019 12:38:08