matio-cpp  v0.2.5
A C++ wrapper of the matio library, with memory ownership handling, to read and write .mat files.
Span.h
Go to the documentation of this file.
1 #ifndef MATIOCPP_SPAN_H
2 #define MATIOCPP_SPAN_H
4 //
5 // Copyright (c) 2015 Microsoft Corporation. All rights reserved.
6 //
7 // This code is licensed under the MIT License (MIT).
8 //
9 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
10 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
11 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
12 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
13 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
14 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
15 // THE SOFTWARE.
16 //
18 
19 //Most of this file has been taken from https://github.com/Microsoft/GSL/blob/master/include/gsl/span
20 //and https://github.com/robotology/idyntree/blob/master/src/core/include/iDynTree/Core/Span.h
21 
22 /*
23  * Copyright (C) 2020 Fondazione Istituto Italiano di Tecnologia
24  *
25  * This software may be modified and distributed under the terms of the
26  * BSD-2-Clause license (https://opensource.org/licenses/BSD-2-Clause).
27  */
28 
29 
31 
32 namespace matioCpp
33 {
34 
35 namespace SpanUtils {
36 
37 template <typename... Ts> struct make_void { typedef void type; };
38 template <typename... Ts> using void_t = typename make_void<Ts...>::type;
39 
40 //Small utility to detect if type T has value_type defined
41 template <typename T, typename = void> struct is_value_defined : std::false_type
42 {
43 };
44 
45 template <typename T>
46 struct is_value_defined<T, void_t<typename T::value_type>> : std::true_type
47 {
48 };
49 
50 //Small utility to detect if type T has element_type defined
51 template <typename T, typename = void> struct is_element_defined : std::false_type
52 {
53 };
54 
55 template <typename T>
56 struct is_element_defined<T, void_t<typename T::element_type>> : std::true_type
57 {
58 };
59 
60 //Small utility to detect if class T has the data() method defined
61 template <typename T, typename = void> struct has_data_method : std::false_type
62 {
63 };
64 
65 template <typename T>
66 struct has_data_method<T, void_t<decltype(std::declval<T>().data())>> : std::true_type
67 {
68 };
69 
70 //Small utility to detect if class T has the size() method defined
71 template <typename T, typename = void> struct has_size_method : std::false_type
72 {
73 };
74 
75 template <typename T>
76 struct has_size_method<T, void_t<decltype(std::declval<T>().size())>> : std::true_type
77 {
78 };
79 
80 //Small utility to detect if class T defines value_type
81 template< class, typename = void >
83 
84 template< class T >
85 struct has_type_member<T, void_t<typename T::value_type>> : std::true_type { };
86 
87 //container_data is a utility metafunction to detect the type of container. If T is not a supported container, it throws
88  // an assertion at compile time.
89 template <typename T, typename = void>
91 {
92  static_assert(dependent_false<T>::value, "Unable to detect type of data in the container.");
93 };
94 
95 template <typename T>
96 struct container_data<T, typename std::enable_if<has_type_member<T>::value>::type>
97 {
98  using type = typename T::value_type;
99 };
100 
101 // This specialization is enabled if <code>T::value_type<\code> is not available, but the method <code>data()<\code> is.
102 template <typename T>
103 struct container_data<T, typename std::enable_if<!has_type_member<T>::value && has_data_method<T>::value>::type>
104 {
106 };
107 
108 //This specialization is enabled if T is an array.
109 template <typename T>
110 struct container_data<T, typename std::enable_if<std::is_array<T>::value>::type>
111 {
112  using type = typename std::remove_all_extents_t<T>;
113 };
114 
115 //is_span_constructible is a utility metafunction to check if matioCpp::Span is constructible given a reference to Class.
116 template <typename Class, typename = void>
118 {};
119 
120 template <typename Class>
122  typename std::enable_if<
123  std::is_constructible<Span<typename container_data<Class>::type>, Class&>::value>::type>
125 {};
126 
127 }
128 
129 // implementation details
130 namespace details
131 {
132  template <class T>
134  {
135  };
136 
137  template <class ElementType, std::ptrdiff_t Extent>
138  struct is_span_oracle<matioCpp::Span<ElementType, Extent>> : std::true_type
139  {
140  };
141 
142  template <class T>
143  struct is_span : public is_span_oracle<std::remove_cv_t<T>>
144  {
145  };
146 
147  template <class T>
149  {
150  };
151 
152  template <class ElementType, std::size_t Extent>
153  struct is_std_array_oracle<std::array<ElementType, Extent>> : std::true_type
154  {
155  };
156 
157  template <class T>
158  struct is_std_array : public is_std_array_oracle<std::remove_cv_t<T>>
159  {
160  };
161 
162  template <std::ptrdiff_t From, std::ptrdiff_t To>
164  : public std::integral_constant<bool, From == To || From == matioCpp::dynamic_extent ||
165  To == matioCpp::dynamic_extent>
166  {
167  };
168 
169  template <class From, class To>
171  : public std::integral_constant<bool, std::is_convertible<From (*)[], To (*)[]>::value>
172  {
173  };
174 
175  template <class Span, bool IsConst>
177  {
178  using element_type_ = typename Span::element_type;
179 
180  public:
181 
183  using value_type = std::remove_cv_t<element_type_>;
185 
186  using reference = std::conditional_t<IsConst, const element_type_, element_type_>&;
187  using pointer = std::add_pointer_t<reference>;
188 
189  span_iterator() = default;
190 
191  MATIOCPP_CONSTEXPR span_iterator(const Span* span, typename Span::index_type idx) noexcept
192  : span_(span), index_(idx)
193  {}
194 
196  template<bool B, std::enable_if_t<!B && IsConst>* = nullptr>
198  : span_iterator(other.span_, other.index_)
199  {
200  }
201 
203  {
204  assert(index_ != span_->size());
205  return *(span_->data() + index_);
206  }
207 
209  {
210  assert(index_ != span_->size());
211  return span_->data() + index_;
212  }
213 
215  {
216  assert(0 <= index_ && index_ != span_->size());
217  ++index_;
218  return *this;
219  }
220 
222  {
223  auto ret = *this;
224  ++(*this);
225  return ret;
226  }
227 
229  {
230  assert(index_ != 0 && index_ <= span_->size());
231  --index_;
232  return *this;
233  }
234 
236  {
237  auto ret = *this;
238  --(*this);
239  return ret;
240  }
241 
243  {
244  auto ret = *this;
245  return ret += n;
246  }
247 
249  {
250  assert((index_ + n) >= 0 && (index_ + n) <= span_->size());
251  index_ += n;
252  return *this;
253  }
254 
256  {
257  auto ret = *this;
258  return ret -= n;
259  }
260 
262 
264  {
265  assert(span_ == rhs.span_);
266  return index_ - rhs.index_;
267  }
268 
270  {
271  return *(*this + n);
272  }
273 
275  span_iterator rhs) noexcept
276  {
277  return lhs.span_ == rhs.span_ && lhs.index_ == rhs.index_;
278  }
279 
281  span_iterator rhs) noexcept
282  {
283  return !(lhs == rhs);
284  }
285 
287  span_iterator rhs) noexcept
288  {
289  return lhs.index_ < rhs.index_;
290  }
291 
293  span_iterator rhs) noexcept
294  {
295  return !(rhs < lhs);
296  }
297 
299  span_iterator rhs) noexcept
300  {
301  return rhs < lhs;
302  }
303 
305  span_iterator rhs) noexcept
306  {
307  return !(rhs > lhs);
308  }
309 
310  protected:
311  const Span* span_ = nullptr;
313  };
314 
315  template <class Span, bool IsConst>
319  {
320  return rhs + n;
321  }
322 
323  template <class Span, bool IsConst>
324  MATIOCPP_CONSTEXPR span_iterator<Span, IsConst>
327  {
328  return rhs - n;
329  }
330 
331  template <std::ptrdiff_t Ext>
333  {
334  public:
336 
337  static_assert(Ext >= 0, "A fixed-size span must be >= 0 in size.");
338 
340 
341  template <index_type Other>
343  {
344  static_assert(Other == Ext || Other == dynamic_extent,
345  "Mismatch between fixed-size extent and size of initializing data.");
346  assert(ext.size() == Ext);
347  }
348 
350 
351  MATIOCPP_CONSTEXPR index_type size() const noexcept { return Ext; }
352  };
353 
354  template <>
356  {
357  public:
359 
360  template <index_type Other>
362  {
363  }
364 
365  explicit MATIOCPP_CONSTEXPR extent_type(index_type size) : size_(size) { assert(size >= 0); }
366 
367  MATIOCPP_CONSTEXPR index_type size() const noexcept { return size_; }
368 
369  private:
370  index_type size_;
371  };
372 
373  template <class ElementType, std::ptrdiff_t Extent, std::ptrdiff_t Offset, std::ptrdiff_t Count>
375  {
376  using type = Span<ElementType, Count != dynamic_extent ? Count : (Extent != dynamic_extent ? Extent - Offset : Extent)>;
377  };
378 } // namespace details
379 
380 // [span], class template span
381 template <class ElementType, std::ptrdiff_t Extent>
382 class Span
383 {
384 public:
385  // constants and types
386  using element_type = ElementType;
387  using value_type = std::remove_cv_t<ElementType>;
392 
397 
399 
400 #if defined(MATIOCPP_USE_STATIC_CONSTEXPR_WORKAROUND)
401  static constexpr const index_type extent { Extent };
402 #else
403  static constexpr index_type extent { Extent };
404 #endif
405 
406 #ifndef SWIG
407  // [span.cons], span constructors, copy, assignment, and destructor
408  template <bool Dependent = false,
409  // "Dependent" is needed to make "std::enable_if_t<Dependent || Extent <= 0>" SFINAE,
410  // since "std::enable_if_t<Extent <= 0>" is ill-formed when Extent is greater than 0.
411  class = std::enable_if_t<(Dependent || Extent <= 0)>>
412  MATIOCPP_CONSTEXPR Span() noexcept : storage_(nullptr, details::extent_type<0>())
413  {
414  }
415 #endif
416 
417  MATIOCPP_CONSTEXPR Span(pointer ptr, index_type count) : storage_(ptr, count) {}
418 
419  MATIOCPP_CONSTEXPR Span(pointer firstElem, pointer lastElem)
420  : storage_(firstElem, std::distance(firstElem, lastElem))
421  {
422  }
423 
424  template <std::size_t N>
426  : storage_(KnownNotNull{&arr[0]}, details::extent_type<N>())
427  {
428  }
429 
430  template <std::size_t N, class ArrayElementType = std::remove_const_t<element_type>>
432  : storage_(&arr[0], details::extent_type<N>())
433  {
434  }
435 
436  template <std::size_t N>
437  MATIOCPP_CONSTEXPR Span(const std::array<std::remove_const_t<element_type>, N>& arr) noexcept
438  : storage_(&arr[0], details::extent_type<N>())
439  {
440  }
441 
442  // NB: the SFINAE here uses .data() as a incomplete/imperfect proxy for the requirement
443  // on Container to be a contiguous sequence container.
444 #ifndef SWIG
445  template <class Container,
446  class = std::enable_if_t<SpanUtils::has_data_method<Container>::value && SpanUtils::has_size_method<Container>::value>,
447  class = std::enable_if_t<
448  !details::is_span<Container>::value && !details::is_std_array<Container>::value &&
449  std::is_convertible<decltype(std::declval<Container>().data()), pointer>::value>>
450  MATIOCPP_CONSTEXPR Span(Container& cont) : Span(cont.data(), static_cast<index_type>(cont.size()))
451  {
452  }
453 
454  template <class Container,
455  class = std::enable_if_t<SpanUtils::has_data_method<Container>::value && SpanUtils::has_size_method<Container>::value>,
456  class = std::enable_if_t<
457  std::is_const<element_type>::value && !details::is_span<Container>::value &&
458  std::is_convertible<decltype(std::declval<Container>().data()), pointer>::value>>
459  MATIOCPP_CONSTEXPR Span(const Container& cont) : Span(cont.data(), static_cast<index_type>(cont.size()))
460  {
461  }
462 #endif
463 
464  MATIOCPP_CONSTEXPR Span(const Span& other) noexcept = default;
465 
466 #ifndef SWIG
467  template <
468  class OtherElementType, std::ptrdiff_t OtherExtent,
469  class = std::enable_if_t<
473  : storage_(other.data(), details::extent_type<OtherExtent>(other.size()))
474  {
475  }
476 #endif
477 
478  ~Span() noexcept = default;
479  MATIOCPP_CONSTEXPR Span& operator=(const Span& other) noexcept = default;
480 
481  // [span.sub], span subviews
482  template <std::ptrdiff_t Count>
484  {
485  assert(Count >= 0 && Count <= size());
486  return {data(), Count};
487  }
488 
489  template <std::ptrdiff_t Count>
491  {
492  assert(Count >= 0 && size() - Count >= 0);
493  return {data() + (size() - Count), Count};
494  }
495 
496 #ifndef SWIG
497  template <std::ptrdiff_t Offset, std::ptrdiff_t Count = dynamic_extent>
498  MATIOCPP_CONSTEXPR auto subspan() const -> typename details::calculate_subspan_type<ElementType, Extent, Offset, Count>::type
499  {
500  assert((Offset >= 0 && size() - Offset >= 0) &&
501  (Count == dynamic_extent || (Count >= 0 && Offset + Count <= size())));
502 
503  return {data() + Offset, Count == dynamic_extent ? size() - Offset : Count};
504  }
505 #endif
506 
508  {
509  assert(count >= 0 && count <= size());
510  return {data(), count};
511  }
512 
514  {
515  return make_subspan(size() - count, dynamic_extent, subspan_selector<Extent>{});
516  }
517 
519  index_type count = dynamic_extent) const
520  {
521  return make_subspan(offset, count, subspan_selector<Extent>{});
522  }
523 
524 
525  // [span.obs], span observers
526  MATIOCPP_CONSTEXPR index_type size() const noexcept { return storage_.size(); }
528  {
529  return size() * static_cast<index_type>(sizeof(element_type));
530  }
531  MATIOCPP_CONSTEXPR bool empty() const noexcept { return size() == 0; }
532 
533  // [span.elem], span element access
535  {
536  assert(idx >= 0 && idx < storage_.size());
537  return data()[idx];
538  }
539 
542  {
543  assert(idx >= 0 && idx < storage_.size());
544  data()[idx] = val;
545  return true;
546  }
547 
548  MATIOCPP_CONSTEXPR reference at(index_type idx) const { return this->operator[](idx); }
549  MATIOCPP_CONSTEXPR reference operator()(index_type idx) const { return this->operator[](idx); }
550  MATIOCPP_CONSTEXPR pointer data() const noexcept { return storage_.data(); }
551 
552  // [span.iter], span iterator support
553  MATIOCPP_CONSTEXPR iterator begin() const noexcept { return {this, 0}; }
554  MATIOCPP_CONSTEXPR iterator end() const noexcept { return {this, size()}; }
555 
556  MATIOCPP_CONSTEXPR const_iterator cbegin() const noexcept { return {this, 0}; }
557  MATIOCPP_CONSTEXPR const_iterator cend() const noexcept { return {this, size()}; }
558 
561 
564 
565 private:
566 
567  // Needed to remove unnecessary null check in subspans
568  struct KnownNotNull
569  {
570  pointer p;
571  };
572 
573  // this implementation detail class lets us take advantage of the
574  // empty base class optimization to pay for only storage of a single
575  // pointer in the case of fixed-size spans
576  template <class ExtentType>
577  class storage_type : public ExtentType
578  {
579  public:
580  // KnownNotNull parameter is needed to remove unnecessary null check
581  // in subspans and constructors from arrays
582  template <class OtherExtentType>
583  MATIOCPP_CONSTEXPR storage_type(KnownNotNull data, OtherExtentType ext) : ExtentType(ext), data_(data.p)
584  {
585  assert(ExtentType::size() >= 0);
586  }
587 
588 
589  template <class OtherExtentType>
590  MATIOCPP_CONSTEXPR storage_type(pointer data, OtherExtentType ext) : ExtentType(ext), data_(data)
591  {
592  assert(ExtentType::size() >= 0);
593  assert(data || ExtentType::size() == 0);
594  }
595 
596  MATIOCPP_CONSTEXPR pointer data() const noexcept { return data_; }
597 
598  private:
599  pointer data_;
600  };
601 
602  storage_type<details::extent_type<Extent>> storage_;
603 
604  // The rest is needed to remove unnecessary null check
605  // in subspans and constructors from arrays
606  MATIOCPP_CONSTEXPR Span(KnownNotNull ptr, index_type count) : storage_(ptr, count) {}
607 
608  template <std::ptrdiff_t CallerExtent>
609  class subspan_selector {};
610 
611  template <std::ptrdiff_t CallerExtent>
612  Span<element_type, dynamic_extent> make_subspan(index_type offset,
613  index_type count,
614  subspan_selector<CallerExtent>) const
615  {
616  Span<element_type, dynamic_extent> tmp(*this);
617  return tmp.subspan(offset, count);
618  }
619 
620  Span<element_type, dynamic_extent> make_subspan(index_type offset,
621  index_type count,
622  subspan_selector<dynamic_extent>) const
623  {
624  assert(offset >= 0 && size() - offset >= 0);
625  if (count == dynamic_extent)
626  {
627  return { KnownNotNull{ data() + offset }, size() - offset };
628  }
629 
630  assert(count >= 0 && size() - offset >= count);
631  return { KnownNotNull{ data() + offset }, count };
632  }
633 };
634 
635 #if defined(MATIOCPP_USE_STATIC_CONSTEXPR_WORKAROUND)
636 template <class ElementType, std::ptrdiff_t Extent>
638 #endif
639 
640 
641 // [span.comparison], span comparison operators
642 template <class ElementType, std::ptrdiff_t FirstExtent, std::ptrdiff_t SecondExtent>
645 {
646  return std::equal(l.begin(), l.end(), r.begin(), r.end());
647 }
648 
649 template <class ElementType, std::ptrdiff_t Extent>
652 {
653  return !(l == r);
654 }
655 
656 template <class ElementType, std::ptrdiff_t Extent>
659 {
660  return std::lexicographical_compare(l.begin(), l.end(), r.begin(), r.end());
661 }
662 
663 template <class ElementType, std::ptrdiff_t Extent>
666 {
667  return !(l > r);
668 }
669 
670 template <class ElementType, std::ptrdiff_t Extent>
673 {
674  return r < l;
675 }
676 
677 template <class ElementType, std::ptrdiff_t Extent>
680 {
681  return !(l < r);
682 }
683 
684 namespace details
685 {
686  // if we only supported compilers with good constexpr support then
687  // this pair of classes could collapse down to a constexpr function
688 
689  // we should use a narrow_cast<> to go to std::size_t, but older compilers may not see it as
690  // constexpr
691  // and so will fail compilation of the template
692 #ifndef SWIG
693  template <class ElementType, std::ptrdiff_t Extent>
695  : std::integral_constant<std::ptrdiff_t,
696  static_cast<std::ptrdiff_t>(sizeof(ElementType) *
697  static_cast<std::size_t>(Extent))>
698  {
699  };
700 
701  template <class ElementType>
702  struct calculate_byte_size<ElementType, dynamic_extent>
703  : std::integral_constant<std::ptrdiff_t, dynamic_extent>
704  {
705  };
706 #endif
707 }
708 
709 
710 //
711 // make_span() - Utility functions for creating spans
712 //
713 template <class ElementType>
715 {
716  return Span<ElementType>(ptr, count);
717 }
718 
719 template <class ElementType>
720 MATIOCPP_CONSTEXPR Span<ElementType> make_span(ElementType* firstElem, ElementType* lastElem)
721 {
722  return Span<ElementType>(firstElem, lastElem);
723 }
724 
725 template <class ElementType, std::size_t N>
726 MATIOCPP_CONSTEXPR Span<ElementType, N> make_span(ElementType (&arr)[N]) noexcept
727 {
728  return Span<ElementType, N>(arr);
729 }
730 
731 template <class Container, typename = typename std::enable_if<SpanUtils::is_value_defined<Container>::value>::type>
733 {
735 }
736 
737 template <class Container, typename = typename std::enable_if<SpanUtils::is_value_defined<Container>::value>::type>
739 {
741 }
742 
743 template <class Ptr>
745 {
746  return Span<typename Ptr::element_type>(cont, count);
747 }
748 
749 template <class Ptr, typename = typename std::enable_if<!SpanUtils::is_value_defined<Ptr>::value && SpanUtils::is_element_defined<Ptr>::value>::type>
751 {
753 }
754 
755 template <class Container, typename = typename std::enable_if<!SpanUtils::is_value_defined<Container>::value &&
756  !SpanUtils::is_element_defined<Container>::value &&
757  SpanUtils::has_data_method<Container>::value>::type>
759 {
761 }
762 
763 template <class Container, typename = typename std::enable_if<!SpanUtils::is_value_defined<Container>::value &&
764  !SpanUtils::is_element_defined<Container>::value &&
765  SpanUtils::has_data_method<Container>::value>::type>
767 {
769 }
770 
771 namespace SpanUtils {
772 //is_make_span_callable is a utility metafunction to check if matioCpp::make_span can be called given the input Class
773 template <typename Class, typename = void>
775 {};
776 
777 template <typename Class>
778 struct is_make_span_callable<Class, void_t<decltype(make_span(std::declval<Class>()))>> : std::true_type
779 {
780 };
781 
782 }
783 
784 } // namespace matioCpp
785 
786 #ifdef _MSC_VER
787 #if _MSC_VER < 1910
788 #undef constexpr
789 #pragma pop_macro("constexpr")
790 
791 #endif // _MSC_VER < 1910
792 
793 #pragma warning(pop)
794 #endif // _MSC_VER
795 
796 #endif // MATIOCPP_SPAN_H
#define MATIOCPP_CONSTEXPR
MATIOCPP_CONSTEXPR reverse_iterator rend() const noexcept
Definition: Span.h:560
MATIOCPP_CONSTEXPR Span(pointer ptr, index_type count)
Definition: Span.h:417
element_type * pointer
Definition: Span.h:389
MATIOCPP_CONSTEXPR bool setVal(index_type idx, const_reference val)
Definition: Span.h:541
MATIOCPP_CONSTEXPR Span() noexcept
Definition: Span.h:412
MATIOCPP_CONSTEXPR Span(const Span< OtherElementType, OtherExtent > &other)
Definition: Span.h:472
MATIOCPP_CONSTEXPR const_reverse_iterator crbegin() const noexcept
Definition: Span.h:562
MATIOCPP_CONSTEXPR reference operator[](index_type idx) const
Definition: Span.h:534
std::remove_cv_t< ElementType > value_type
Definition: Span.h:387
MATIOCPP_CONSTEXPR Span< element_type, dynamic_extent > subspan(index_type offset, index_type count=dynamic_extent) const
Definition: Span.h:518
MATIOCPP_CONSTEXPR const_reverse_iterator crend() const noexcept
Definition: Span.h:563
MATIOCPP_CONSTEXPR reference operator()(index_type idx) const
Definition: Span.h:549
MATIOCPP_CONSTEXPR Span(element_type(&arr)[N]) noexcept
Definition: Span.h:425
MATIOCPP_CONSTEXPR auto subspan() const -> typename details::calculate_subspan_type< ElementType, Extent, Offset, Count >::type
Definition: Span.h:498
MATIOCPP_CONSTEXPR Span< element_type, Count > first() const
Definition: Span.h:483
MATIOCPP_CONSTEXPR Span(std::array< ArrayElementType, N > &arr) noexcept
Definition: Span.h:431
MATIOCPP_CONSTEXPR index_type size_bytes() const noexcept
Definition: Span.h:527
element_type & reference
Definition: Span.h:390
MATIOCPP_CONSTEXPR reverse_iterator rbegin() const noexcept
Definition: Span.h:559
MATIOCPP_CONSTEXPR const_iterator cend() const noexcept
Definition: Span.h:557
MATIOCPP_CONSTEXPR iterator begin() const noexcept
Definition: Span.h:553
MATIOCPP_CONSTEXPR Span(pointer firstElem, pointer lastElem)
Definition: Span.h:419
MATIOCPP_CONSTEXPR Span< element_type, dynamic_extent > last(index_type count) const
Definition: Span.h:513
MATIOCPP_CONSTEXPR index_type size() const noexcept
Definition: Span.h:526
MATIOCPP_CONSTEXPR Span< element_type, Count > last() const
Definition: Span.h:490
MATIOCPP_CONSTEXPR Span< element_type, dynamic_extent > first(index_type count) const
Definition: Span.h:507
~Span() noexcept=default
ElementType element_type
Definition: Span.h:386
MATIOCPP_CONSTEXPR reference at(index_type idx) const
Definition: Span.h:548
MATIOCPP_CONSTEXPR bool empty() const noexcept
Definition: Span.h:531
MATIOCPP_CONSTEXPR Span(const std::array< std::remove_const_t< element_type >, N > &arr) noexcept
Definition: Span.h:437
MATIOCPP_CONSTEXPR Span(const Span &other) noexcept=default
std::ptrdiff_t index_type
Definition: Span.h:388
MATIOCPP_CONSTEXPR const_reference getVal(index_type idx) const
Definition: Span.h:540
MATIOCPP_CONSTEXPR iterator end() const noexcept
Definition: Span.h:554
static constexpr index_type extent
Definition: Span.h:403
MATIOCPP_CONSTEXPR const_iterator cbegin() const noexcept
Definition: Span.h:556
MATIOCPP_CONSTEXPR pointer data() const noexcept
Definition: Span.h:550
const element_type & const_reference
Definition: Span.h:391
MATIOCPP_CONSTEXPR extent_type(extent_type< Other > ext)
Definition: Span.h:361
MATIOCPP_CONSTEXPR index_type size() const noexcept
Definition: Span.h:367
MATIOCPP_CONSTEXPR extent_type(index_type size)
Definition: Span.h:365
MATIOCPP_CONSTEXPR extent_type(extent_type< Other > ext)
Definition: Span.h:342
MATIOCPP_CONSTEXPR extent_type(index_type size)
Definition: Span.h:349
MATIOCPP_CONSTEXPR index_type size() const noexcept
Definition: Span.h:351
MATIOCPP_CONSTEXPR extent_type() noexcept
Definition: Span.h:339
std::ptrdiff_t index_type
Definition: Span.h:335
MATIOCPP_CONSTEXPR friend bool operator>=(span_iterator lhs, span_iterator rhs) noexcept
Definition: Span.h:304
typename Span::index_type difference_type
Definition: Span.h:184
MATIOCPP_CONSTEXPR reference operator[](difference_type n) const
Definition: Span.h:269
MATIOCPP_CONSTEXPR span_iterator & operator-=(difference_type n)
Definition: Span.h:261
MATIOCPP_CONSTEXPR friend bool operator>(span_iterator lhs, span_iterator rhs) noexcept
Definition: Span.h:298
MATIOCPP_CONSTEXPR difference_type operator-(span_iterator rhs) const
Definition: Span.h:263
MATIOCPP_CONSTEXPR span_iterator operator-(difference_type n) const
Definition: Span.h:255
MATIOCPP_CONSTEXPR friend bool operator<=(span_iterator lhs, span_iterator rhs) noexcept
Definition: Span.h:292
MATIOCPP_CONSTEXPR span_iterator & operator++()
Definition: Span.h:214
MATIOCPP_CONSTEXPR reference operator*() const
Definition: Span.h:202
MATIOCPP_CONSTEXPR pointer operator->() const
Definition: Span.h:208
MATIOCPP_CONSTEXPR friend bool operator<(span_iterator lhs, span_iterator rhs) noexcept
Definition: Span.h:286
MATIOCPP_CONSTEXPR span_iterator operator+(difference_type n) const
Definition: Span.h:242
MATIOCPP_CONSTEXPR span_iterator & operator+=(difference_type n)
Definition: Span.h:248
MATIOCPP_CONSTEXPR span_iterator(const span_iterator< Span, B > &other) noexcept
Definition: Span.h:197
MATIOCPP_CONSTEXPR span_iterator operator--(int)
Definition: Span.h:235
MATIOCPP_CONSTEXPR friend bool operator==(span_iterator lhs, span_iterator rhs) noexcept
Definition: Span.h:274
MATIOCPP_CONSTEXPR span_iterator(const Span *span, typename Span::index_type idx) noexcept
Definition: Span.h:191
std::remove_cv_t< element_type_ > value_type
Definition: Span.h:183
MATIOCPP_CONSTEXPR span_iterator operator++(int)
Definition: Span.h:221
std::add_pointer_t< reference > pointer
Definition: Span.h:187
MATIOCPP_CONSTEXPR span_iterator & operator--()
Definition: Span.h:228
MATIOCPP_CONSTEXPR friend bool operator!=(span_iterator lhs, span_iterator rhs) noexcept
Definition: Span.h:280
std::conditional_t< IsConst, const element_type_, element_type_ > & reference
Definition: Span.h:186
T count(T... args)
T equal(T... args)
T lexicographical_compare(T... args)
typename make_void< Ts... >::type void_t
Definition: Span.h:38
MATIOCPP_CONSTEXPR span_iterator< Span, IsConst > operator-(typename span_iterator< Span, IsConst >::difference_type n, span_iterator< Span, IsConst > rhs)
Definition: Span.h:325
MATIOCPP_CONSTEXPR span_iterator< Span, IsConst > operator+(typename span_iterator< Span, IsConst >::difference_type n, span_iterator< Span, IsConst > rhs)
Definition: Span.h:317
MATIOCPP_CONSTEXPR Span< ElementType > make_span(ElementType *ptr, typename Span< ElementType >::index_type count)
Definition: Span.h:714
MATIOCPP_CONSTEXPR bool operator!=(Span< ElementType, Extent > l, Span< ElementType, Extent > r)
Definition: Span.h:650
MATIOCPP_CONSTEXPR const std::ptrdiff_t dynamic_extent
MATIOCPP_CONSTEXPR bool operator<(Span< ElementType, Extent > l, Span< ElementType, Extent > r)
Definition: Span.h:657
MATIOCPP_CONSTEXPR bool operator>=(Span< ElementType, Extent > l, Span< ElementType, Extent > r)
Definition: Span.h:678
MATIOCPP_CONSTEXPR bool operator>(Span< ElementType, Extent > l, Span< ElementType, Extent > r)
Definition: Span.h:671
MATIOCPP_CONSTEXPR bool operator<=(Span< ElementType, Extent > l, Span< ElementType, Extent > r)
Definition: Span.h:664
MATIOCPP_CONSTEXPR bool operator==(Span< ElementType, FirstExtent > l, Span< ElementType, SecondExtent > r)
Definition: Span.h:643
STL namespace.
dependent_false is a type-dependent expression that is always false.