Skip to content

Commit

Permalink
No default constructor for geometry
Browse files Browse the repository at this point in the history
Defaulting to the point 0,0 is not particularly useful and could hide bugs.
  • Loading branch information
jfirebaugh committed Apr 29, 2016
1 parent a86baac commit c961ad2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 6 additions & 0 deletions include/mapbox/geometry/geometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ struct geometry : geometry_base<T>
{
using value_type = T;
using geometry_base<T>::geometry_base;

/*
* The default constructor would create a point geometry with default-constructed coordinates;
* i.e. (0, 0). Since this is not particularly useful, and could hide bugs, it is disabled.
*/
geometry() = delete;

This comment has been minimized.

Copy link
@artemp

artemp May 3, 2016

Contributor

@jfirebaugh - this is actually useful for memory allocation strategies and usabilities with boost::geometry and boost::spirit::qi for example

};

template <typename T, template <typename...> class Cont>
Expand Down
3 changes: 0 additions & 3 deletions tests/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ void testGeometry() {
void testGeometryCollection() {
geometry_collection<double> gc1;
assert(gc1.size() == 0);

geometry_collection<double> gc2(10);
assert(gc2.size() == 10);
}

int main() {
Expand Down

0 comments on commit c961ad2

Please sign in to comment.