2011-09-05 21:06:31 +02:00
|
|
|
#ifndef utils_hh_INCLUDED
|
|
|
|
#define utils_hh_INCLUDED
|
|
|
|
|
2011-09-09 21:24:18 +02:00
|
|
|
#include "exception.hh"
|
|
|
|
|
2011-09-08 02:08:55 +02:00
|
|
|
#include <memory>
|
|
|
|
|
2011-09-05 21:06:31 +02:00
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
|
|
|
struct LineAndColumn
|
|
|
|
{
|
|
|
|
int line;
|
|
|
|
int column;
|
|
|
|
|
|
|
|
LineAndColumn(int line = 0, int column = 0)
|
|
|
|
: line(line), column(column) {}
|
|
|
|
};
|
|
|
|
|
2011-09-06 20:33:35 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2011-09-08 02:08:55 +02:00
|
|
|
template<typename T>
|
|
|
|
bool operator== (const std::unique_ptr<T>& lhs, T* rhs)
|
|
|
|
{
|
|
|
|
return lhs.get() == rhs;
|
|
|
|
}
|
2011-09-06 20:33:35 +02:00
|
|
|
|
2011-09-05 21:06:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // utils_hh_INCLUDED
|