Skip to content

Commit 5b8d1af

Browse files
committed
[math] Support implicit conversion from TVectorT to std::span
1 parent 98d4d9e commit 5b8d1af

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

math/matrix/inc/TVectorT.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include "TMatrixTSym.h"
2525
#include "TMatrixTSparse.h"
2626

27+
#include <ROOT/RSpan.hxx>
28+
2729
template<class Element> class TVectorT : public TObject {
2830

2931
protected:
@@ -82,6 +84,20 @@ template<class Element> class TVectorT : public TObject {
8284
inline Element *data() { return fElements; }
8385
inline const Element *data() const { return fElements; }
8486

87+
// Implicit conversion of TVectorT to std::span, both non-const and const
88+
// version. Can be removed once the minimum C++ standard in C++20, because
89+
// then it's enough to implement the contiguous_range and sized_range
90+
// concepts. This should alredy be the case since data() and size() are
91+
// available.
92+
inline operator std::span<Element>()
93+
{
94+
return std::span<Element>{data(), size()};
95+
}
96+
inline operator std::span<const Element>() const
97+
{
98+
return std::span<const Element>{data(), size()};
99+
}
100+
85101
inline void Invalidate () { SetBit(kStatus); }
86102
inline void MakeValid () { ResetBit(kStatus); }
87103
inline Bool_t IsValid () const { return !TestBit(kStatus); }

0 commit comments

Comments
 (0)