CARLA
 
载入中...
搜索中...
未找到
Iterator.h
浏览该文件的文档.
1// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#pragma once
8
9#include <boost/iterator/transform_iterator.hpp>
10
11namespace carla {
12namespace iterator {
13
14 /// Creates an iterator over non-const references to the keys of a map.
15 template <typename It>
16 inline static auto make_map_keys_iterator(It it) {
17 using first_value_type = typename It::value_type::first_type;
18 using decay_first_value_type = typename std::remove_cv_t<typename std::remove_reference_t<first_value_type>>;
19 using ref_to_first = decay_first_value_type &;
20 return boost::make_transform_iterator(it, [](auto &pair) -> ref_to_first { return pair.first; });
21 }
22
23 /// Creates an iterator over const references to the keys of a map.
24 template <typename It>
25 inline static auto make_map_keys_const_iterator(It it) {
26 using first_value_type = typename It::value_type::first_type;
27 using decay_first_value_type = typename std::remove_cv_t<typename std::remove_reference_t<first_value_type>>;
28 using const_ref_to_first = const decay_first_value_type &;
29 return boost::make_transform_iterator(it, [](const auto &pair) -> const_ref_to_first { return pair.first; });
30 }
31
32 /// Creates an iterator over non-const references to the values of a map.
33 template <typename It>
34 inline static auto make_map_values_iterator(It it) {
35 using second_value_type = typename It::value_type::second_type;
36 using decay_second_value_type = typename std::remove_cv_t<typename std::remove_reference_t<second_value_type>>;
37 using ref_to_second = decay_second_value_type &;
38 return boost::make_transform_iterator(it, [](auto &pair) -> ref_to_second { return pair.second; });
39 }
40
41 /// Creates an iterator over const references to the values of a map.
42 template <typename It>
43 inline static auto make_map_values_const_iterator(It it) {
44 using second_value_type = typename It::value_type::second_type;
45 using decay_second_value_type = typename std::remove_cv_t<typename std::remove_reference_t<second_value_type>>;
46 using const_ref_to_second = const decay_second_value_type &;
47 return boost::make_transform_iterator(it, [](const auto &pair) -> const_ref_to_second { return pair.second; });
48 }
49
50} // namespace iterator
51} // namespace carla
static auto make_map_keys_const_iterator(It it)
Creates an iterator over const references to the keys of a map.
Definition Iterator.h:25
static auto make_map_values_iterator(It it)
Creates an iterator over non-const references to the values of a map.
Definition Iterator.h:34
static auto make_map_keys_iterator(It it)
Creates an iterator over non-const references to the keys of a map.
Definition Iterator.h:16
static auto make_map_values_const_iterator(It it)
Creates an iterator over const references to the values of a map.
Definition Iterator.h:43
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133