diff --git a/src/command-line-app.cpp b/src/command-line-app.cpp index f038f1ff1..47859d4d6 100644 --- a/src/command-line-app.cpp +++ b/src/command-line-app.cpp @@ -97,7 +97,7 @@ void command_line_app_t::init_logging_options(bool with_progress, bool with_sql) if (with_progress) { add_option_function( "--log-progress", - [&](std::string const &arg) { + [](std::string const &arg) { if (arg == "true") { get_logger().enable_progress(); } else if (arg == "false") { diff --git a/src/command-line-parser.cpp b/src/command-line-parser.cpp index a89370d73..871b2d65d 100644 --- a/src/command-line-parser.cpp +++ b/src/command-line-parser.cpp @@ -431,7 +431,7 @@ options_t parse_command_line(int argc, char *argv[]) options.projection = reprojection_t::create_projection(arg); #else - [&](int) { + [](int) { throw std::runtime_error{ "Generic projections not available in this build."}; #endif diff --git a/src/geom-box.cpp b/src/geom-box.cpp index 0b49cfb82..a27caff8a 100644 --- a/src/geom-box.cpp +++ b/src/geom-box.cpp @@ -99,7 +99,7 @@ box_t envelope(geom::collection_t const &geom) box_t envelope(geometry_t const &geom) { - return geom.visit([&](auto const &g) { return envelope(g); }); + return geom.visit([](auto const &g) { return envelope(g); }); } } // namespace geom diff --git a/src/geom-functions.cpp b/src/geom-functions.cpp index 34e5d3fd3..507acc57f 100644 --- a/src/geom-functions.cpp +++ b/src/geom-functions.cpp @@ -41,18 +41,16 @@ std::string_view geometry_type(geometry_t const &geom) { using namespace std::literals::string_view_literals; return geom.visit(overloaded{ - [&](geom::nullgeom_t const & /*input*/) { return "NULL"sv; }, - [&](geom::point_t const & /*input*/) { return "POINT"sv; }, - [&](geom::linestring_t const & /*input*/) { return "LINESTRING"sv; }, - [&](geom::polygon_t const & /*input*/) { return "POLYGON"sv; }, - [&](geom::multipoint_t const & /*input*/) { return "MULTIPOINT"sv; }, - [&](geom::multilinestring_t const & /*input*/) { + [](geom::nullgeom_t const & /*input*/) { return "NULL"sv; }, + [](geom::point_t const & /*input*/) { return "POINT"sv; }, + [](geom::linestring_t const & /*input*/) { return "LINESTRING"sv; }, + [](geom::polygon_t const & /*input*/) { return "POLYGON"sv; }, + [](geom::multipoint_t const & /*input*/) { return "MULTIPOINT"sv; }, + [](geom::multilinestring_t const & /*input*/) { return "MULTILINESTRING"sv; }, - [&](geom::multipolygon_t const & /*input*/) { - return "MULTIPOLYGON"sv; - }, - [&](geom::collection_t const & /*input*/) { + [](geom::multipolygon_t const & /*input*/) { return "MULTIPOLYGON"sv; }, + [](geom::collection_t const & /*input*/) { return "GEOMETRYCOLLECTION"sv; }}); } @@ -62,7 +60,7 @@ std::string_view geometry_type(geometry_t const &geom) std::size_t num_geometries(geometry_t const &geom) { return geom.visit( - [&](auto const &input) { return input.num_geometries(); }); + [](auto const &input) { return input.num_geometries(); }); } /****************************************************************************/ @@ -353,14 +351,14 @@ geometry_t segmentize(geometry_t const &input, double max_segment_length) double area(geometry_t const &geom) { return std::abs(geom.visit( - overloaded{[&](geom::nullgeom_t const & /*input*/) { return 0.0; }, - [&](geom::collection_t const &input) { + overloaded{[](geom::nullgeom_t const & /*input*/) { return 0.0; }, + [](geom::collection_t const &input) { return std::accumulate(input.cbegin(), input.cend(), 0.0, [](double sum, auto const &geom) { return sum + area(geom); }); }, - [&](auto const &input) { + [](auto const &input) { return static_cast(boost::geometry::area(input)); }})); } @@ -390,21 +388,21 @@ double spherical_area(geometry_t const &geom) assert(geom.srid() == PROJ_LATLONG); return std::abs(geom.visit(overloaded{ - [&](geom::nullgeom_t const & /*input*/) { return 0.0; }, - [&](geom::collection_t const &input) { + [](geom::nullgeom_t const & /*input*/) { return 0.0; }, + [](geom::collection_t const &input) { return std::accumulate(input.cbegin(), input.cend(), 0.0, [](double sum, auto const &geom) { return sum + spherical_area(geom); }); }, - [&](geom::polygon_t const &input) { return spherical_area(input); }, - [&](geom::multipolygon_t const &input) { + [](geom::polygon_t const &input) { return spherical_area(input); }, + [](geom::multipolygon_t const &input) { return std::accumulate(input.cbegin(), input.cend(), 0.0, - [&](double sum, auto const &geom) { + [](double sum, auto const &geom) { return sum + spherical_area(geom); }); }, - [&](auto const & /*input*/) { return 0.0; }})); + [](auto const & /*input*/) { return 0.0; }})); } /****************************************************************************/ @@ -412,15 +410,15 @@ double spherical_area(geometry_t const &geom) double length(geometry_t const &geom) { return geom.visit(overloaded{ - [&](geom::nullgeom_t const & /*input*/) { return 0.0; }, - [&](geom::collection_t const &input) { + [](geom::nullgeom_t const & /*input*/) { return 0.0; }, + [](geom::collection_t const &input) { double total = 0.0; for (auto const &item : input) { total += length(item); } return total; }, - [&](auto const &input) { + [](auto const &input) { return static_cast(boost::geometry::length(input)); }}); } diff --git a/src/geom.cpp b/src/geom.cpp index 120f56ced..952e0fe85 100644 --- a/src/geom.cpp +++ b/src/geom.cpp @@ -40,7 +40,7 @@ std::size_t dimension(collection_t const &geom) std::size_t dimension(geometry_t const &geom) { - return geom.visit([&](auto const &input) { return dimension(input); }); + return geom.visit([](auto const &input) { return dimension(input); }); } } // namespace geom diff --git a/src/locator.cpp b/src/locator.cpp index 4cdf9baaf..2f5f010c9 100644 --- a/src/locator.cpp +++ b/src/locator.cpp @@ -91,7 +91,7 @@ void locator_t::build_index() void locator_t::all_intersecting_visit(geom::geometry_t const &geom, std::set *results) { - geom.visit(overloaded{[&](geom::nullgeom_t const & /*val*/) {}, + geom.visit(overloaded{[](geom::nullgeom_t const & /*val*/) {}, [&](geom::collection_t const &val) { for (auto const &sgeom : val) { all_intersecting_visit(sgeom, results); @@ -120,7 +120,7 @@ std::set locator_t::all_intersecting(geom::geometry_t const &geom) void locator_t::first_intersecting_visit(geom::geometry_t const &geom, std::string *result) { - geom.visit(overloaded{[&](geom::nullgeom_t const & /*val*/) {}, + geom.visit(overloaded{[](geom::nullgeom_t const & /*val*/) {}, [&](geom::collection_t const &val) { for (auto const &sgeom : val) { first_intersecting_visit(sgeom, result); diff --git a/src/wkb.cpp b/src/wkb.cpp index 629bb4d59..f310ecd11 100644 --- a/src/wkb.cpp +++ b/src/wkb.cpp @@ -174,7 +174,7 @@ void write_collection(std::string *data, geom::collection_t const &geom, for (auto const &item : geom) { item.visit(overloaded{ - [&](geom::nullgeom_t const & /*input*/) {}, + [](geom::nullgeom_t const & /*input*/) {}, [&](geom::point_t const &input) { write_point(data, input); }, [&](geom::linestring_t const &input) { write_linestring(data, input);