diff --git a/src/utils.hh b/src/utils.hh index 75640cd8..88d95e11 100644 --- a/src/utils.hh +++ b/src/utils.hh @@ -13,6 +13,24 @@ struct LineAndColumn : line(line), column(column) {} }; +template +struct ReversedContainer +{ + ReversedContainer(Container& container) : container(container) {} + Container& container; + + decltype(container.rbegin()) begin() { return container.rbegin(); } + decltype(container.rend()) end() { return container.rend(); } +}; + +template +ReversedContainer reversed(Container& container) +{ + return ReversedContainer(container); +} + + + } #endif // utils_hh_INCLUDED