Define and use IteratorRange
This commit is contained in:
parent
90e400b0a7
commit
6909bdf398
|
@ -727,4 +727,16 @@ Final_action<F> finally (F f)
|
|||
return Final_action<F>(f);
|
||||
}
|
||||
|
||||
/*
|
||||
* A convenience for use with range-for
|
||||
*/
|
||||
template <typename Iterator>
|
||||
struct IteratorRange : public std::pair<Iterator, Iterator> {
|
||||
IteratorRange (Iterator &&a, Iterator &&b)
|
||||
: std::pair<Iterator, Iterator> { std::move(a), std::move(b) } {}
|
||||
|
||||
Iterator begin() const { return this->first; }
|
||||
Iterator end() const { return this->second; }
|
||||
};
|
||||
|
||||
#endif // __AUDACITY_MEMORY_X_H__
|
||||
|
|
|
@ -443,7 +443,7 @@ wxString Tags::GetTag(const wxString & name) const
|
|||
|
||||
Tags::Iterators Tags::GetRange() const
|
||||
{
|
||||
return std::make_pair(mMap.begin(), mMap.end());
|
||||
return { mMap.begin(), mMap.end() };
|
||||
}
|
||||
|
||||
void Tags::SetTag(const wxString & name, const wxString & value)
|
||||
|
|
|
@ -104,13 +104,7 @@ class AUDACITY_DLL_API Tags final : public XMLTagHandler {
|
|||
bool HasTag(const wxString & name) const;
|
||||
wxString GetTag(const wxString & name) const;
|
||||
|
||||
using IterPair = std::pair<TagMap::const_iterator, TagMap::const_iterator>;
|
||||
struct Iterators : public IterPair {
|
||||
Iterators(IterPair p) : IterPair(p) {}
|
||||
// Define begin() and end() for convenience in range-for
|
||||
auto begin() -> decltype(first) const { return first; }
|
||||
auto end() -> decltype(second) const { return second; }
|
||||
};
|
||||
using Iterators = IteratorRange<TagMap::const_iterator>;
|
||||
Iterators GetRange() const;
|
||||
|
||||
void SetTag(const wxString & name, const wxString & value);
|
||||
|
|
Loading…
Reference in New Issue