Skip to content

Commit acbdfcf

Browse files
committed
Use cbegin()/cend() instead of begin()/end() to signal const use
1 parent 35c6d73 commit acbdfcf

File tree

9 files changed

+36
-35
lines changed

9 files changed

+36
-35
lines changed

src/expire-tiles.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ quadkey_list_t expire_tiles::get_tiles()
270270
{
271271
quadkey_list_t tiles;
272272
tiles.reserve(m_dirty_tiles.size());
273-
tiles.assign(m_dirty_tiles.begin(), m_dirty_tiles.end());
273+
tiles.assign(m_dirty_tiles.cbegin(), m_dirty_tiles.cend());
274274
std::sort(tiles.begin(), tiles.end());
275275
m_dirty_tiles.clear();
276276
return tiles;
@@ -288,8 +288,8 @@ void expire_tiles::merge_and_destroy(expire_tiles *other)
288288
using std::swap;
289289
swap(m_dirty_tiles, other->m_dirty_tiles);
290290
} else {
291-
m_dirty_tiles.insert(other->m_dirty_tiles.begin(),
292-
other->m_dirty_tiles.end());
291+
m_dirty_tiles.insert(other->m_dirty_tiles.cbegin(),
292+
other->m_dirty_tiles.cend());
293293
other->m_dirty_tiles.clear();
294294
}
295295
}

src/geom-from-osm.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void create_polygon(geometry_t *geom, osmium::Way const &way,
110110
}
111111

112112
auto const &area = assembler.get_area();
113-
auto const &ring = *area.begin<osmium::OuterRing>();
113+
auto const &ring = *area.cbegin<osmium::OuterRing>();
114114

115115
fill_point_list(&polygon.outer(), ring);
116116
}
@@ -169,7 +169,7 @@ void create_multilinestring(geometry_t *geom,
169169
auto ways = buffer.select<osmium::Way>();
170170
if (ways.size() == 1 && !force_multi) {
171171
auto &line = geom->set<linestring_t>();
172-
auto const &way = *ways.begin();
172+
auto const &way = *ways.cbegin();
173173
if (!fill_point_list(&line, way.nodes())) {
174174
geom->reset();
175175
}
@@ -228,7 +228,7 @@ void create_multipolygon(geometry_t *geom, osmium::Relation const &relation,
228228
}
229229
} else {
230230
auto &polygon = geom->set<polygon_t>();
231-
fill_polygon(&polygon, area, *area.outer_rings().begin());
231+
fill_polygon(&polygon, area, *area.outer_rings().cbegin());
232232
}
233233
}
234234

src/geom-functions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ class without_first
258258

259259
point_list_t::const_iterator begin()
260260
{
261-
assert(m_list->begin() != m_list->end());
262-
return std::next(m_list->begin());
261+
assert(m_list->cbegin() != m_list->cend());
262+
return std::next(m_list->cbegin());
263263
}
264264

265265
point_list_t::const_iterator end() { return m_list->end(); }

src/hex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ std::string decode_hex(std::string_view hex_string)
6767
wkb.reserve(hex_string.size() / 2);
6868

6969
// NOLINTNEXTLINE(llvm-qualified-auto, readability-qualified-auto)
70-
for (auto hex = hex_string.begin(); hex != hex_string.end();) {
70+
for (auto hex = hex_string.cbegin(); hex != hex_string.cend();) {
7171
unsigned int const c = decode_hex_char(*hex++);
7272
wkb += static_cast<char>((c << 4U) | decode_hex_char(*hex++));
7373
}

src/output-flex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ void flush_tables(std::vector<table_connection_t> &table_connections)
280280
void create_expire_tables(std::vector<expire_output_t> const &expire_outputs,
281281
connection_params_t const &connection_params)
282282
{
283-
if (std::all_of(expire_outputs.begin(), expire_outputs.end(),
283+
if (std::all_of(expire_outputs.cbegin(), expire_outputs.cend(),
284284
[](auto const &expire_output) {
285285
return expire_output.table().empty();
286286
})) {

tests/common-import.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class data_t
6969
template <typename CONTAINER>
7070
explicit data_t(CONTAINER const &objects)
7171
{
72-
std::copy(std::begin(objects), std::end(objects),
72+
std::copy(std::cbegin(objects), std::cend(objects),
7373
std::back_inserter(m_objects));
7474
}
7575

@@ -78,13 +78,13 @@ class data_t
7878
template <typename CONTAINER>
7979
void add(CONTAINER const &objects)
8080
{
81-
std::copy(std::begin(objects), std::end(objects),
81+
std::copy(std::cbegin(objects), std::cend(objects),
8282
std::back_inserter(m_objects));
8383
}
8484

8585
void add(std::initializer_list<char const *> const &objects)
8686
{
87-
std::copy(std::begin(objects), std::end(objects),
87+
std::copy(std::cbegin(objects), std::cend(objects),
8888
std::back_inserter(m_objects));
8989
}
9090

tests/test-expire-tiles.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ TEST_CASE("simple expire z1", "[NoDB]")
100100
auto const tiles = get_tiles_ordered(&et, minzoom, maxzoom);
101101
CHECK(tiles.size() == 4);
102102

103-
auto itr = tiles.begin();
103+
auto itr = tiles.cbegin();
104104
CHECK(*(itr++) == tile_t(1, 0, 0));
105105
CHECK(*(itr++) == tile_t(1, 1, 0));
106106
CHECK(*(itr++) == tile_t(1, 0, 1));
@@ -120,7 +120,7 @@ TEST_CASE("simple expire z3", "[NoDB]")
120120
auto const tiles = get_tiles_ordered(&et, minzoom, maxzoom);
121121
CHECK(tiles.size() == 4);
122122

123-
auto itr = tiles.begin();
123+
auto itr = tiles.cbegin();
124124
CHECK(*(itr++) == tile_t(3, 3, 3));
125125
CHECK(*(itr++) == tile_t(3, 4, 3));
126126
CHECK(*(itr++) == tile_t(3, 3, 4));
@@ -140,7 +140,7 @@ TEST_CASE("simple expire z18", "[NoDB]")
140140
auto const tiles = get_tiles_ordered(&et, minzoom, maxzoom);
141141
CHECK(tiles.size() == 4);
142142

143-
auto itr = tiles.begin();
143+
auto itr = tiles.cbegin();
144144
CHECK(*(itr++) == tile_t(18, 131071, 131071));
145145
CHECK(*(itr++) == tile_t(18, 131072, 131071));
146146
CHECK(*(itr++) == tile_t(18, 131071, 131072));
@@ -159,7 +159,7 @@ TEST_CASE("simple expire z10 bounds 0, 0", "[NoDB]")
159159
auto const tiles = get_tiles_ordered(&et, minzoom, maxzoom);
160160
CHECK(tiles.size() == 1);
161161

162-
auto itr = tiles.begin();
162+
auto itr = tiles.cbegin();
163163
CHECK(*(itr++) == tile_t(10, 0, 0));
164164
}
165165

@@ -175,7 +175,7 @@ TEST_CASE("simple expire z10 bounds 0, 1023", "[NoDB]")
175175
auto const tiles = get_tiles_ordered(&et, minzoom, maxzoom);
176176
CHECK(tiles.size() == 1);
177177

178-
auto itr = tiles.begin();
178+
auto itr = tiles.cbegin();
179179
CHECK(*(itr++) == tile_t(10, 0, 1023));
180180
}
181181

@@ -191,7 +191,7 @@ TEST_CASE("simple expire z10 bounds 1023, 0", "[NoDB]")
191191
auto const tiles = get_tiles_ordered(&et, minzoom, maxzoom);
192192
CHECK(tiles.size() == 1);
193193

194-
auto itr = tiles.begin();
194+
auto itr = tiles.cbegin();
195195
CHECK(*(itr++) == tile_t(10, 1023, 0));
196196
}
197197

@@ -207,7 +207,7 @@ TEST_CASE("simple expire z10 bounds 1023, 1023", "[NoDB]")
207207
auto const tiles = get_tiles_ordered(&et, minzoom, maxzoom);
208208
CHECK(tiles.size() == 1);
209209

210-
auto itr = tiles.begin();
210+
auto itr = tiles.cbegin();
211211
CHECK(*(itr++) == tile_t(10, 1023, 1023));
212212
}
213213

@@ -223,7 +223,7 @@ TEST_CASE("expire a simple line", "[NoDB]")
223223
auto const tiles = get_tiles_ordered(&et, zoom, zoom);
224224
CHECK(tiles.size() == 3);
225225

226-
auto itr = tiles.begin();
226+
auto itr = tiles.cbegin();
227227
CHECK(*(itr++) == tile_t(18, 140221, 82055));
228228
CHECK(*(itr++) == tile_t(18, 140222, 82055));
229229
CHECK(*(itr++) == tile_t(18, 140223, 82055));
@@ -241,7 +241,7 @@ TEST_CASE("expire a line near the tile border", "[NoDB]")
241241
auto const tiles = get_tiles_ordered(&et, zoom, zoom);
242242
REQUIRE(tiles.size() == 4);
243243

244-
auto itr = tiles.begin();
244+
auto itr = tiles.cbegin();
245245
CHECK(*(itr++) == tile_t(18, 140222, 82055));
246246
CHECK(*(itr++) == tile_t(18, 140223, 82055));
247247
CHECK(*(itr++) == tile_t(18, 140222, 82056));
@@ -331,7 +331,7 @@ TEST_CASE("simple expire z17 and z18", "[NoDB]")
331331
auto const tiles = get_tiles_ordered(&et, minzoom, maxzoom);
332332
CHECK(tiles.size() == 8);
333333

334-
auto itr = tiles.begin();
334+
auto itr = tiles.cbegin();
335335
CHECK(*(itr++) == tile_t(18, 131071, 131071));
336336
CHECK(*(itr++) == tile_t(17, 65535, 65535));
337337
CHECK(*(itr++) == tile_t(18, 131072, 131071));
@@ -356,7 +356,7 @@ TEST_CASE("simple expire z17 and z18 in one superior tile", "[NoDB]")
356356
auto const tiles = get_tiles_ordered(&et, minzoom, maxzoom);
357357
CHECK(tiles.size() == 5);
358358

359-
auto itr = tiles.begin();
359+
auto itr = tiles.cbegin();
360360
CHECK(*(itr++) == tile_t(18, 131070, 131070));
361361
CHECK(*(itr++) == tile_t(17, 65535, 65535));
362362
CHECK(*(itr++) == tile_t(18, 131071, 131070));

tests/test-middle.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -517,14 +517,14 @@ void check_way(std::shared_ptr<middle_pgsql_t> const &mid,
517517
CHECK(std::strcmp(orig_way.user(), way.user()) == 0);
518518

519519
REQUIRE(orig_way.tags().size() == way.tags().size());
520-
for (auto it1 = orig_way.tags().begin(), it2 = way.tags().begin();
521-
it1 != orig_way.tags().end(); ++it1, ++it2) {
520+
for (auto it1 = orig_way.tags().cbegin(), it2 = way.tags().cbegin();
521+
it1 != orig_way.tags().cend(); ++it1, ++it2) {
522522
CHECK(*it1 == *it2);
523523
}
524524

525525
REQUIRE(orig_way.nodes().size() == way.nodes().size());
526-
for (auto it1 = orig_way.nodes().begin(), it2 = way.nodes().begin();
527-
it1 != orig_way.nodes().end(); ++it1, ++it2) {
526+
for (auto it1 = orig_way.nodes().cbegin(), it2 = way.nodes().cbegin();
527+
it1 != orig_way.nodes().cend(); ++it1, ++it2) {
528528
CHECK(*it1 == *it2);
529529
}
530530

@@ -792,15 +792,16 @@ void check_relation(std::shared_ptr<middle_pgsql_t> const &mid,
792792
CHECK(std::strcmp(orig_relation.user(), relation.user()) == 0);
793793

794794
REQUIRE(orig_relation.tags().size() == relation.tags().size());
795-
for (auto it1 = orig_relation.tags().begin(), it2 = relation.tags().begin();
796-
it1 != orig_relation.tags().end(); ++it1, ++it2) {
795+
for (auto it1 = orig_relation.tags().cbegin(),
796+
it2 = relation.tags().cbegin();
797+
it1 != orig_relation.tags().cend(); ++it1, ++it2) {
797798
CHECK(*it1 == *it2);
798799
}
799800

800801
REQUIRE(orig_relation.members().size() == relation.members().size());
801-
for (auto it1 = orig_relation.members().begin(),
802-
it2 = relation.members().begin();
803-
it1 != orig_relation.members().end(); ++it1, ++it2) {
802+
for (auto it1 = orig_relation.members().cbegin(),
803+
it2 = relation.members().cbegin();
804+
it1 != orig_relation.members().cend(); ++it1, ++it2) {
804805
CHECK(it1->type() == it2->type());
805806
CHECK(it1->ref() == it2->ref());
806807
CHECK(std::strcmp(it1->role(), it2->role()) == 0);

tests/test-options-parse.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ char const *const TEST_PBF = "foo.pbf";
2121

2222
void bad_opt(std::vector<char const *> opts, char const *msg)
2323
{
24-
opts.insert(opts.begin(), "osm2pgsql");
24+
opts.insert(opts.cbegin(), "osm2pgsql");
2525
opts.push_back(TEST_PBF);
2626

2727
REQUIRE_THROWS_WITH(
@@ -31,7 +31,7 @@ void bad_opt(std::vector<char const *> opts, char const *msg)
3131

3232
options_t opt(std::vector<char const *> opts)
3333
{
34-
opts.insert(opts.begin(), "osm2pgsql");
34+
opts.insert(opts.cbegin(), "osm2pgsql");
3535
opts.push_back(TEST_PBF);
3636

3737
return parse_command_line((int)opts.size(), (char **)opts.data());

0 commit comments

Comments
 (0)