3#ifndef JFC_CONTIGUOUS_VIEW_H
4#define JFC_CONTIGUOUS_VIEW_H
20template<
class value_type_param>
23 using size_type = size_t;
24 using value_type = value_type_param;
28 template<
class Po
inter>
31 , m_pEnd(pBegin + aSize)
37 template<
class Iterator>
45 template<
class Collection>
54 template<
class Po
inter>
56 :
contiguous_view(static_cast<value_type_param *>(&(*pBegin)), [pBegin, pEnd]() {
59 for(
auto iter(pBegin); iter != pEnd; ++iter)
67 template<
class Iterator>
70 static_cast<value_type_param *>(&(*aEnd)))
89 [[nodiscard]]
constexpr value_type &
operator[](
const size_type index) {
90 return *(m_pBegin + index);
94 [[nodiscard]]
constexpr const value_type &
operator[](
const size_type index)
const {
95 return *(m_pBegin + index);
99 [[nodiscard]]
constexpr value_type_param *
begin() {
104 [[nodiscard]]
constexpr value_type_param *
begin()
const {
105 return static_cast<const value_type *
>(m_pBegin);
109 [[nodiscard]]
constexpr value_type_param *
end() {
114 [[nodiscard]]
constexpr value_type_param *
end()
const {
115 return static_cast<const value_type *
>(m_pEnd);
119 [[nodiscard]]
constexpr size_t size()
const {
124 [[nodiscard]]
constexpr bool empty()
const {
129 value_type_param *m_pBegin =
nullptr;
131 value_type_param *m_pEnd =
nullptr;
133 size_type m_Size = 0;
constexpr contiguous_view(const contiguous_view &)=default
support copy semantics
constexpr bool empty() const
whether or not size is 0
Definition contiguous_view.h:124
constexpr const value_type & operator[](const size_type index) const
access an element by index, constant
Definition contiguous_view.h:94
constexpr size_t size() const
number of elements accessible through the view
Definition contiguous_view.h:119
constexpr contiguous_view(contiguous_view &&)=default
support move semantics
constexpr value_type & operator[](const size_type index)
access an element by index
Definition contiguous_view.h:89
constexpr value_type_param * end()
pointer to the element following the last
Definition contiguous_view.h:109
constexpr value_type_param * begin()
pointer to the beginning of the data
Definition contiguous_view.h:99
contiguous_view(Pointer *pBegin, Pointer *pEnd)
Definition contiguous_view.h:55
constexpr value_type_param * end() const
pointer to the element following the last, constant
Definition contiguous_view.h:114
constexpr value_type_param * begin() const
pointer to the beginning of the data, constant
Definition contiguous_view.h:104
constexpr contiguous_view & operator=(contiguous_view &&rhv)=default
support move semantics
contiguous_view(Iterator aBegin, Iterator aEnd)
construct from a pair of iterators.
Definition contiguous_view.h:68
constexpr contiguous_view()=default
constructs an empty view
constexpr contiguous_view(Pointer *pBegin, const size_type aSize)
Definition contiguous_view.h:29
constexpr contiguous_view(Collection &aCollection)
Definition contiguous_view.h:46
constexpr contiguous_view & operator=(const contiguous_view &rhv)=default
support copy semantics
constexpr contiguous_view(Iterator iBegin, const size_type aSize)
Definition contiguous_view.h:38