mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-21 10:40:53 +03:00
f58cbf0b98
this permits to use range-based for loops to iterate on reversed containers. Should work on any container implementing rbegin and rend.
37 lines
698 B
C++
37 lines
698 B
C++
#ifndef utils_hh_INCLUDED
|
|
#define utils_hh_INCLUDED
|
|
|
|
namespace Kakoune
|
|
{
|
|
|
|
struct LineAndColumn
|
|
{
|
|
int line;
|
|
int column;
|
|
|
|
LineAndColumn(int line = 0, int column = 0)
|
|
: line(line), column(column) {}
|
|
};
|
|
|
|
template<typename Container>
|
|
struct ReversedContainer
|
|
{
|
|
ReversedContainer(Container& container) : container(container) {}
|
|
Container& container;
|
|
|
|
decltype(container.rbegin()) begin() { return container.rbegin(); }
|
|
decltype(container.rend()) end() { return container.rend(); }
|
|
};
|
|
|
|
template<typename Container>
|
|
ReversedContainer<Container> reversed(Container& container)
|
|
{
|
|
return ReversedContainer<Container>(container);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif // utils_hh_INCLUDED
|