Skip to content

Commit

Permalink
Added one more utility
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikołaj Małecki committed Sep 13, 2023
1 parent 5cf9b9e commit 8a7fa07
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions srtcore/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,19 @@ inline std::pair<Type1&, Type2&> Tie(Type1& var1, Type2& var2)
return std::pair<Type1&, Type2&>(var1, var2);
}

// This can be used in conjunction with Tie to simplify the code
// in loops around a whole container:
// list<string>::const_iterator it, end;
// Tie(it, end) = All(list_container);
template<class Container>
std::pair<typename Container::iterator, typename Container::iterator>
inline All(Container& c) { return std::make_pair(c.begin(), c.end()); }

template<class Container>
std::pair<typename Container::const_iterator, typename Container::const_iterator>
inline All(const Container& c) { return std::make_pair(c.begin(), c.end()); }


template <class Container, class Value>
inline void FringeValues(const Container& from, std::map<Value, size_t>& out)
{
Expand Down

0 comments on commit 8a7fa07

Please sign in to comment.