10#ifndef XTENSOR_ACCESSIBLE_HPP
11#define XTENSOR_ACCESSIBLE_HPP
13#include "xexception.hpp"
14#include "xstrides.hpp"
15#include "xtensor_forward.hpp"
33 using derived_type = D;
35 using reference =
typename inner_types::reference;
36 using const_reference =
typename inner_types::const_reference;
37 using size_type =
typename inner_types::size_type;
39 size_type
size() const noexcept;
41 size_type
shape(size_type index) const;
43 template <class... Args>
44 const_reference at(Args... args) const;
47 disable_integral_t<S, const_reference> operator[](const S& index) const;
49 const_reference operator[](std::initializer_list<I> index) const;
50 const_reference operator[](size_type i) const;
52 template <class... Args>
53 const_reference periodic(Args... args) const;
55 template <class... Args>
59 const_reference
back() const;
74 const derived_type& derived_cast() const noexcept;
92 using derived_type =
typename base_type::derived_type;
93 using reference =
typename base_type::reference;
94 using size_type =
typename base_type::size_type;
96 template <
class... Args>
97 reference at(Args... args);
100 disable_integral_t<S, reference> operator[](
const S& index);
102 reference operator[](std::initializer_list<I> index);
103 reference operator[](size_type i);
105 template <
class... Args>
106 reference periodic(Args... args);
112 using base_type::operator[];
113 using base_type::back;
114 using base_type::front;
115 using base_type::periodic;
130 derived_type& derived_cast() noexcept;
143 return compute_size(derived_cast().
shape());
152 return derived_cast().shape().size();
161 return derived_cast().shape()[index];
174 template <
class... Args>
177 check_access(derived_cast().
shape(), args...);
178 return derived_cast().operator()(args...);
190 -> disable_integral_t<S, const_reference>
192 return derived_cast().element(index.cbegin(), index.cend());
199 return derived_cast().element(index.begin(), index.end());
205 return derived_cast().operator()(i);
216 template <
class... Args>
220 return derived_cast()(
static_cast<size_type
>(args)...);
229 return *derived_cast().begin();
238 return *std::prev(derived_cast().end());
247 template <
class... Args>
250 return check_in_bounds(derived_cast().
shape(), args...);
256 return *
static_cast<const derived_type*
>(
this);
273 template <
class... Args>
276 check_access(derived_cast().
shape(), args...);
277 return derived_cast().operator()(args...);
290 return derived_cast().element(index.cbegin(), index.cend());
297 return derived_cast().element(index.begin(), index.end());
301 inline auto xaccessible<D>::operator[](size_type i) -> reference
303 return derived_cast().operator()(i);
314 template <
class... Args>
318 return derived_cast()(args...);
327 return *derived_cast().begin();
336 return *std::prev(derived_cast().end());
342 return *
static_cast<derived_type*
>(
this);
Base class for implementation of common expression access methods.
reference back()
Returns a reference to the last element of the expression.
reference front()
Returns a reference to the first element of the expression.
Base class for implementation of common expression constant access methods.
const_reference front() const
Returns a constant reference to first the element of the expression.
size_type size() const noexcept
Returns the size of the expression.
size_type dimension() const noexcept
Returns the number of dimensions of the expression.
bool in_bounds(Args... args) const
Returns true only if the the specified position is a valid entry in the expression.
const_reference back() const
Returns a constant reference to last the element of the expression.
size_type shape(size_type index) const
Returns the i-th dimension of the expression.
void normalize_periodic(const S &shape, Args &... args)
Normalise an index of a periodic array.
standard mathematical functions for xexpressions