31 #include <boost/mpl/contains.hpp>
32 #include <boost/mpl/vector.hpp>
33 #include <boost/mpl/placeholders.hpp>
34 #include <boost/mpl/count_if.hpp>
35 #include <boost/mpl/size.hpp>
40 template<
typename ATYPE>
class array_view;
43 #define IDX_ARRAY(IT,i)\
44 std::array<size_t,sizeof...(IT)>{{size_t(i)...}}
58 static const bool value = std::is_integral<T>::value ||
59 std::is_same<T,slice>::value;
73 template<
typename ...ITYPES>
92 using _ = boost::mpl::placeholders::_;
94 typedef typename boost::mpl::vector<ITYPES...>
types;
97 typedef boost::mpl::count_if<types,is_index_type_pred<_>>
n_index_types;
101 static const bool value = n_index_types::value ==
102 int(boost::mpl::size<types>::value);
122 template<
typename ...ITYPES>
129 typedef typename boost::mpl::contains<
130 typename boost::mpl::vector<ITYPES...>
::type,
135 static const bool value = type::value;
155 template<
typename ...ITYPES>
161 typedef typename boost::mpl::contains<
164 typedef typename boost::mpl::contains<
165 typename boost::mpl::vector<ITYPES...>::type,
size_t>::type
169 static const bool value = has_slice::value || has_size_t::value;
199 static const bool value = std::is_same<T,slice>::value;
215 static const bool value = std::is_same<T,slice>::value;
251 template<
typename ATYPE>
268 template<
typename ATYPE>
272 typedef typename ATYPE::value_type&
type;
278 template<
typename CTYPE>
279 using enable_element_cont = std::enable_if<!is_index_type<CTYPE>::value &&
282 template<
typename CTYPE>
283 using enable_view_cont = std::enable_if<!is_index_type<CTYPE>::value &&
312 template<
typename ATYPE>
343 typedef std::array<size_t,
sizeof...(ITYPES)> array_type;
345 array_type buffer{{size_t(indexes)...}};
349 size_t offset = map.offset(array_type{{size_t(indexes)...}});
374 static type
get_value(
const CTYPE &c,MAP &map,ITYPES ...indexes)
376 typedef std::array<size_t,
sizeof...(ITYPES)> array_type;
378 array_type buffer{{size_t(indexes)...}};
382 size_t offset = map.offset(array_type{{size_t(indexes)...}});
398 template<
typename ATYPE>
427 typedef std::array<
slice,
sizeof...(ITYPES)> array_type;
430 array_type{{slice(indexes)...}}));
453 static type
get_value(
const CTYPE &c,MAP &,ITYPES ...indexes)
455 typedef std::array<
slice,
sizeof...(ITYPES)> array_type;
458 array_type{{slice(indexes)...}}));
463 template<
typename ATYPE,
466 using view_type_trait = array_view_trait<ATYPE,
467 is_view_index<ITYPES...>::value>;
469 template<
typename ...ITYPES>
470 using enable_valid_index =
std::enable_if<is_index_types<ITYPES...>::value>;
array_view_trait< ATYPE, false >::const_type type
const type (value type)
Definition: array_view_utils.hpp:318
static type get_value(const CTYPE &c, MAP &, ITYPES...indexes)
get const view
Definition: array_view_utils.hpp:453
boost::mpl::contains< typename boost::mpl::vector< ITYPES...>::type, slice >::type has_slice
result type of MPL exrepssion
Definition: array_view_utils.hpp:162
#define EXCEPTION_RECORD
macro creating an instance of ExceptionRecord
Definition: exceptions.hpp:48
check if an index type is a valid index type
Definition: array_view_utils.hpp:55
type erasure array types
Definition: array.hpp:74
array_view_trait< ATYPE, true >::type ref_type
reference type
Definition: array_view_utils.hpp:402
ATYPE::value_type const_type
single element value
Definition: array_view_utils.hpp:274
boost::mpl::contains< typename boost::mpl::vector< ITYPES...>::type, size_t >::type has_size_t
result type of MPL expression
Definition: array_view_utils.hpp:166
is_index_type< T > type
result type
Definition: array_view_utils.hpp:88
check if valid index
Definition: array_view_utils.hpp:158
boost::mpl::contains< typename boost::mpl::vector< ITYPES...>::type, slice >::type type
result type of MPL expression
Definition: array_view_utils.hpp:132
array_view_trait< ATYPE, false >::type ref_type
reference type
Definition: array_view_utils.hpp:316
boost::mpl::vector< ITYPES...> types
list of types passed by the user
Definition: array_view_utils.hpp:94
Definition: array_view_utils.hpp:299
Definition: add_op.hpp:29
check if view index
Definition: array_view_utils.hpp:181
view trait
Definition: array_view_utils.hpp:238
invoke< std::enable_if< C::value >> enable_if
shortcut for std::enable_if
Definition: sfinae_macros.hpp:108
array_view_trait< ATYPE, true >::const_type type
const reference type
Definition: array_view_utils.hpp:404
array_view< const ATYPE > const_type
const view type
Definition: array_view_utils.hpp:257
index slice
Definition: slice.hpp:49
bool check_indexes(const ITYPE &index, const STYPE &shape)
check indexes
Definition: exception_utils.hpp:167
predicate type for count_if
Definition: array_view_utils.hpp:85
boost::mpl::placeholders::_ _
load the _ placeholder from boost::mpl
Definition: array_view_utils.hpp:92
check a set of types for index
Definition: array_view_utils.hpp:74
boost::mpl::count_if< types, is_index_type_pred< _ > > n_index_types
count all index types
Definition: array_view_utils.hpp:97
static ref_type get_reference(CTYPE &c, MAP &map, ITYPES...indexes)
get reference
Definition: array_view_utils.hpp:341
ATYPE::value_type & type
single element reference
Definition: array_view_utils.hpp:272
array_view< ATYPE > type
non-const view type
Definition: array_view_utils.hpp:255
type erasure for POD data
Definition: value.hpp:46
checks for view index
Definition: array_view_utils.hpp:126
static ref_type get_reference(CTYPE &c, MAP &, ITYPES...indexes)
get view object
Definition: array_view_utils.hpp:425
size_t offset(const MAPT &map, const array_selection &s, const CTYPE &index)
compute offset
Definition: array_selection.hpp:510
static type get_value(const CTYPE &c, MAP &map, ITYPES...indexes)
get value
Definition: array_view_utils.hpp:374
static array_selection create(const CTYPE &s)
static creation function
Definition: array_selection.hpp:215
provides a view on a part of an array
Definition: add_op.hpp:32