1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-02-22 22:21:24 +01:00

Define and use utility template ValueIterator...

... generalizing the fix of commit 7591891 to other cases, making the iterators
safe for adaptation with std::reverse_iterator should the need ever arise
This commit is contained in:
Paul Licameli
2018-12-22 09:35:22 -05:00
parent b4ce681867
commit d261ea2558
4 changed files with 16 additions and 12 deletions

View File

@@ -430,6 +430,19 @@ template< typename T >
ValueRestorer< T > valueRestorer( T& var, const T& newValue )
{ return ValueRestorer< T >{ var, newValue }; }
/**
\brief A convenience for defining iterators that return rvalue types, so that
they cooperate correctly with stl algorithms and std::reverse_iterator
*/
template< typename Value, typename Category = std::forward_iterator_tag >
using ValueIterator = std::iterator<
Category, const Value, ptrdiff_t,
// void pointer type so that operator -> is disabled
void,
// make "reference type" really the same as the value type
const Value
>;
/**
\brief A convenience for use with range-for
*/