libpnicore
container_trait.hpp
1 //
2 // (c) Copyright 2014 DESY, Eugen Wintersberger <eugen.wintersberger@desy.de>
3 //
4 // This file is part of libpnicore.
5 //
6 // libpnicore is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // libpnicore is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with libpnicore. If not, see <http://www.gnu.org/licenses/>.
18 //
19 // ===========================================================================
20 //
21 // Created on: Apr 11, 2014
22 // Author: Eugen Wintersberger
23 //
24 //
25 #pragma once
26 #include <vector>
27 #include <array>
28 #include <list>
29 
30 
31 namespace pni{
32 namespace core{
33 
57  template<typename CTYPE> struct container_trait
58  {
60  static const bool is_random_access = false;
62  static const bool is_iterable = false;
64  static const bool is_contiguous = false;
66  static const bool is_multidim = false;
67  };
68 
69  //-------------------------------------------------------------------------
79  template<typename ...ARGS> struct container_trait<std::vector<ARGS...>>
80  {
82  static const bool is_random_access = true;
84  static const bool is_iterable = true;
86  static const bool is_contiguous = true;
88  static const bool is_multidim = false;
89  };
90 
91  //-------------------------------------------------------------------------
101  template<
102  typename T,
103  size_t N
104  >
105  struct container_trait<std::array<T,N>>
106  {
108  static const bool is_random_access = true;
110  static const bool is_iterable = true;
112  static const bool is_contiguous = true;
114  static const bool is_multidim = false;
115  };
116 
117  //-------------------------------------------------------------------------
126  template<typename ...ARGS> struct container_trait<std::list<ARGS...>>
127  {
129  static const bool is_random_access = false;
131  static const bool is_iterable = true;
133  static const bool is_contiguous = false;
135  static const bool is_multidim = false;
136  };
137 
138 
139 
140 
141 //end of namespace
142 }
143 }
type erasure array types
Definition: array.hpp:74
STL namespace.
static const bool is_random_access
by default false
Definition: container_trait.hpp:60
static const bool is_contiguous
by default false
Definition: container_trait.hpp:64
container trait
Definition: container_trait.hpp:57
Definition: add_op.hpp:29
static const bool is_multidim
by default false
Definition: container_trait.hpp:66
static const bool is_iterable
by default false
Definition: container_trait.hpp:62