The Battle for Wesnoth  1.19.8+dev
ranges.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2021 - 2024
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #pragma once
16 
17 #ifdef __cpp_lib_ranges
18 #include <ranges>
19 #else
20 #include <boost/range/adaptor/filtered.hpp>
21 #include <boost/range/adaptor/map.hpp>
22 #include <boost/range/adaptor/reversed.hpp>
23 #include <boost/range/adaptor/transformed.hpp>
24 #endif
25 
26 namespace utils::views
27 {
28 #ifdef __cpp_lib_ranges
29 
30 using std::views::filter;
31 using std::views::keys;
34 using std::views::values;
35 
36 #else
37 
38 constexpr auto filter = boost::adaptors::filtered;
39 constexpr auto keys = boost::adaptors::map_keys;
40 constexpr auto reverse = boost::adaptors::reversed;
41 constexpr auto transform = boost::adaptors::transformed;
42 constexpr auto values = boost::adaptors::map_values;
43 
44 #endif
45 } // namespace utils::views
constexpr auto transform
Definition: ranges.hpp:41
constexpr auto values
Definition: ranges.hpp:42
constexpr auto reverse
Definition: ranges.hpp:40
constexpr auto keys
Definition: ranges.hpp:39
constexpr auto filter
Definition: ranges.hpp:38