17 #ifndef ROOFIT_ROOFITCORE_INC_ROOSPAN_H_
18 #define ROOFIT_ROOFITCORE_INC_ROOSPAN_H_
34 using iterator =
typename std::span<T>::iterator;
35 using value_type =
typename std::remove_cv<T>::type;
41 constexpr RooSpan(RooSpan&& other) :
42 _auxStorage{std::move(other._auxStorage)},
43 _span{other._span.data(), other._span.size()}
46 constexpr RooSpan(
const RooSpan& other) :
47 _auxStorage{other._auxStorage},
53 template<
typename NON_CONST_T,
54 typename =
typename std::enable_if<std::is_same<const NON_CONST_T, T>::value>::type >
55 constexpr RooSpan(
const RooSpan<NON_CONST_T>& other) :
57 _span{other.data(), other.size()}
61 template <
class InputIterator>
62 constexpr RooSpan(InputIterator beginIn, InputIterator endIn) :
69 constexpr RooSpan(
typename std::span<T>::pointer beginIn,
70 typename std::span<T>::pointer endIn) :
77 constexpr RooSpan(
typename std::span<T>::pointer beginIn,
78 typename std::span<T>::index_type sizeIn) :
80 _span{beginIn, sizeIn}
84 constexpr RooSpan(
const std::vector<
typename std::remove_cv<T>::type>& vec) noexcept :
89 constexpr RooSpan(std::vector<
typename std::remove_cv<T>::type>& vec) noexcept :
98 constexpr RooSpan(std::vector<value_type>&& payload) :
99 _auxStorage{
new std::vector<value_type>(std::forward<std::vector<value_type>>(payload))},
100 _span{_auxStorage->begin(), _auxStorage->end()}
104 RooSpan<T>& operator=(
const RooSpan<T>& other) =
default;
107 constexpr
typename std::span<T>::iterator begin()
const {
108 return _span.begin();
111 constexpr
typename std::span<T>::iterator end()
const {
115 constexpr
typename std::span<T>::pointer data()
const {
119 constexpr
typename std::span<T>::reference operator[](
typename std::span<T>::index_type i)
const noexcept {
123 constexpr
typename std::span<T>::index_type size() const noexcept {
127 constexpr
bool empty() const noexcept {
128 return _span.empty();
131 constexpr
bool isBatch() const noexcept {
137 template <
class Span_t>
138 bool overlaps(
const Span_t& other)
const {
139 return insideSpan(other.begin()) || insideSpan(other.end()-1)
140 || other.insideSpan(begin()) || other.insideSpan(end()-1);
144 template <
typename ptr_t>
145 bool insideSpan(ptr_t ptr)
const {
146 return begin() <= ptr && ptr < end();
154 std::shared_ptr<std::vector<value_type>> _auxStorage;