The Battle for Wesnoth  1.15.12+dev
ranges.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2021 by the Battle for Wesnoth Project https://www.wesnoth.org/
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY.
10 
11  See the COPYING file for more details.
12 */
13 
14 #pragma once
15 
16 #include "global.hpp"
17 
18 #ifdef HAVE_CXX20
19 #include <ranges>
20 #else
21 #include <boost/range/adaptor/reversed.hpp>
22 #endif
23 
24 namespace utils
25 {
26 template<typename T>
27 inline auto reversed_view(T& container)
28 {
29 #ifdef HAVE_CXX20
30  return std::views::reverse(container);
31 #else
32  return boost::adaptors::reverse(container);
33 #endif
34 }
35 
36 } // namespace utils
auto reversed_view(T &container)
Definition: ranges.hpp:27
static void reverse(lua_State *L, StkId from, StkId to)
Definition: lapi.cpp:203