17#ifndef ROOFIT_BATCHCOMPUTE_ROOSPAN_H
18#define ROOFIT_BATCHCOMPUTE_ROOSPAN_H
36 using iterator =
typename std::span<T>::iterator;
54 template<
typename NON_CONST_T,
55 typename =
typename std::enable_if<std::is_same<const NON_CONST_T, T>::value>
::type >
62 template <
class InputIterator>
63 constexpr RooSpan(InputIterator beginIn, InputIterator endIn) :
69 constexpr RooSpan(
typename std::span<T>::pointer beginIn,
70 typename std::span<T>::pointer endIn) :
76 constexpr RooSpan(
typename std::span<T>::pointer beginIn,
77 typename std::span<T>::index_type sizeIn) :
78 _span{beginIn, sizeIn}
82 constexpr RooSpan(
const std::vector<
typename std::remove_cv<T>::type>&
vec) noexcept :
86 constexpr RooSpan(std::vector<
typename std::remove_cv<T>::type>&
vec) noexcept :
92 constexpr RooSpan(std::vector<value_type>&& payload) =
delete;
98 constexpr typename std::span<T>::iterator
begin()
const {
102 constexpr typename std::span<T>::iterator
end()
const {
106 constexpr typename std::span<T>::pointer
data()
const {
111 constexpr typename std::span<T>::reference
operator[](
typename std::span<T>::index_type i)
const noexcept {
115 typename std::span<T>::reference
operator[](
typename std::span<T>::index_type i)
const noexcept {
116 assert(i <
_span.size());
121 constexpr typename std::span<T>::index_type
size() const noexcept {
125 constexpr bool empty() const noexcept {
126 return _span.empty();
135 template <
class Span_t>
136 constexpr bool overlaps(
const Span_t& other)
const {
138 || other.insideSpan(
begin()) || other.insideSpan(
end()-1);
142 template <
typename ptr_t>
144 return begin() <= ptr && ptr <
end();
A simple container to hold a batch of data values.
constexpr RooSpan(std::vector< typename std::remove_cv< T >::type > &vec) noexcept
constexpr bool insideSpan(ptr_t ptr) const
Test if the given pointer/iterator is inside the span.
constexpr std::span< T >::iterator end() const
typename std::remove_cv< T >::type value_type
std::span< T >::reference operator[](typename std::span< T >::index_type i) const noexcept
constexpr RooSpan(InputIterator beginIn, InputIterator endIn)
Construct from a range. Data held by foreign object.
constexpr RooSpan(const RooSpan< NON_CONST_T > &other)
Conversion constructor from <T> to <const T> If the input span owns some memory, the const-version of...
constexpr std::span< T >::pointer data() const
constexpr std::span< T >::index_type size() const noexcept
constexpr RooSpan(const RooSpan &other)
constexpr RooSpan(typename std::span< T >::pointer beginIn, typename std::span< T >::pointer endIn)
Construct from start and end pointers.
constexpr RooSpan(RooSpan &&other)
typename std::span< T >::iterator iterator
constexpr RooSpan(std::vector< value_type > &&payload)=delete
We cannot point to temporary data.
constexpr RooSpan(typename std::span< T >::pointer beginIn, typename std::span< T >::index_type sizeIn)
Construct from start pointer and size.
constexpr bool overlaps(const Span_t &other) const
Test if the span overlaps with other.
constexpr bool isBatch() const noexcept
constexpr RooSpan(const std::vector< typename std::remove_cv< T >::type > &vec) noexcept
constexpr std::span< T >::iterator begin() const
constexpr bool empty() const noexcept
RooSpan & operator=(const RooSpan &other)=default