Skip to content
Snippets Groups Projects
Commit da898965 authored by Enrico Guiraud's avatar Enrico Guiraud
Browse files

[TTreeReader] Fix "int + TTreeReaderArray::Iterator_t"

Thanks Axel!
parent be58dfc5
No related branches found
No related tags found
No related merge requests found
......@@ -154,6 +154,7 @@ public:
}
Iterator_t operator+(std::ptrdiff_t n) const { return Iterator_t(fIndex + n, fArray); }
friend auto operator+(std::ptrdiff_t n, const Iterator_t &it) -> decltype(it + n) { return it + n; }
Iterator_t operator-(std::ptrdiff_t n) const
{
......@@ -207,11 +208,4 @@ protected:
// ClassDefT(TTreeReaderArray, 0);//Accessor to member of an object stored in a collection
};
// FIXME: `n + it` cannot use this overload of operator+ because T cannot be deduced from the type of the iterator
template <typename T>
auto operator+(std::ptrdiff_t n, const typename TTreeReaderArray<T>::iterator &it) -> decltype(it + n)
{
return it + n;
}
#endif // ROOT_TTreeReaderArray
......@@ -64,9 +64,7 @@ void TestReaderArray()
it = it3++;
EXPECT_EQ(it += 1, it3);
// FIXME: `n + it` does not resolve to the right operator+
// EXPECT_EQ((std::ptrdiff_t(2) + arr.begin()) - 1, --(arr.begin() + 2));
EXPECT_EQ((arr.begin() + 2) - 1, --(arr.begin() + 2));
EXPECT_EQ((std::ptrdiff_t(2) + arr.begin()) - 1, --(arr.begin() + 2));
it = std::move(it3);
auto it4 = it--;
EXPECT_EQ(it4 -= 1, it);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment