fix some compiler warnings

This commit is contained in:
Patrick Brosi 2018-07-22 18:37:03 +02:00
parent 0effea29bd
commit 30883e6487
7 changed files with 43 additions and 39 deletions

View file

@ -20,7 +20,7 @@ if(OPENMP_FOUND)
endif()
# set compiler flags, see http://stackoverflow.com/questions/7724569/debug-vs-release-in-cmake
set(CMAKE_CXX_FLAGS "-fopenmp -Ofast -fno-signed-zeros -fno-trapping-math -frename-registers -Wall -Wno-format-extra-args -Wextra -Wformat-nonliteral -Wformat-security -Wformat=2 -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include/ -I/usr/lib/gcc/x86_64-linux-gnu/5/include/")
set(CMAKE_CXX_FLAGS "-fopenmp -Ofast -fno-signed-zeros -fno-trapping-math -frename-registers -Wall -Wno-format-extra-args -Wextra -Wformat-nonliteral -Wformat-security -Wformat=2")
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g -DLOGLEVEL=3")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DLOGLEVEL=2")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DLOGLEVEL=2")
@ -33,12 +33,10 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if ((GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7))
if ((GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif (GCC_VERSION VERSION_EQUAL 4.6)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else ()
message(FATAL_ERROR "${PROJECT_NAME} requires g++ 4.6 or greater.")
message(FATAL_ERROR "${PROJECT_NAME} requires g++ 4.8 or greater!")
endif ()
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -std=c++11")

@ -1 +1 @@
Subproject commit 8d255970a97c31891277f63ba8b39a3ea2b7e133
Subproject commit 3a462c37358da19f10e89f77fb7a277d69c6c4dc

View file

@ -16,5 +16,5 @@ configure_file (
add_executable(pfaedle ${pfaedle_main})
add_library(pfaedle_dep ${pfaedle_SRC})
target_include_directories(pfaedle_dep PUBLIC ${PROJECT_SOURCE_DIR}/src/cppgtfs/src)
include_directories(pfaedle_dep PUBLIC ${PROJECT_SOURCE_DIR}/src/cppgtfs/src)
target_link_libraries(pfaedle pfaedle_dep util xml configparser ad_cppgtfs ${Boost_LIBRARIES} -lpthread)

View file

@ -29,7 +29,7 @@ class Box {
bool operator==(const Box<T>& b) const {
return getLowerLeft() == b.getLowerLeft() &&
getUpperRight == b.getUpperRight();
getUpperRight() == b.getUpperRight();
}
bool operator!=(const Box<T>& p) const { return !(*this == p); }

View file

@ -96,7 +96,7 @@ inline Point<T> centroid(const Box<T> box) {
}
// _____________________________________________________________________________
template <typename T, template <typename> typename Geometry>
template <typename T, template <typename> class Geometry>
inline Point<T> centroid(std::vector<Geometry<T>> multigeo) {
Line<T> a;
for (const auto& g : multigeo) a.push_back(centroid(g));
@ -106,6 +106,7 @@ inline Point<T> centroid(std::vector<Geometry<T>> multigeo) {
// _____________________________________________________________________________
template <typename T>
inline Point<T> rotate(const Point<T>& p, double deg) {
UNUSED(deg);
return p;
}
@ -153,7 +154,7 @@ inline Polygon<T> rotate(Polygon<T> geo, double deg, const Point<T>& c) {
}
// _____________________________________________________________________________
template <typename T, template <typename> typename Geometry>
template <template <typename> class Geometry, typename T>
inline std::vector<Geometry<T>> rotate(std::vector<Geometry<T>> multigeo,
double deg, const Point<T>& c) {
for (size_t i = 0; i < multigeo.size(); i++)
@ -162,7 +163,7 @@ inline std::vector<Geometry<T>> rotate(std::vector<Geometry<T>> multigeo,
}
// _____________________________________________________________________________
template <typename T, template <typename> typename Geometry>
template <template <typename> class Geometry, typename T>
inline std::vector<Geometry<T>> rotate(std::vector<Geometry<T>> multigeo,
double deg) {
auto c = centroid(multigeo);
@ -201,7 +202,7 @@ inline Polygon<T> move(Polygon<T> geo, T x, T y) {
}
// _____________________________________________________________________________
template <typename T, template <typename> typename Geometry>
template <template <typename> class Geometry, typename T>
inline std::vector<Geometry<T>> move(std::vector<Geometry<T>> multigeo, T x,
T y) {
for (size_t i = 0; i < multigeo.size(); i++)
@ -382,8 +383,8 @@ inline bool contains(const Polygon<T>& poly, const Line<T>& l) {
}
// _____________________________________________________________________________
template <typename T, template <typename> typename GeometryA,
template <typename> typename GeometryB>
template <template <typename> class GeometryA,
template <typename> class GeometryB, typename T>
inline bool contains(const std::vector<GeometryA<T>>& multigeo,
const GeometryB<T>& geo) {
for (const auto& g : multigeo)
@ -758,6 +759,7 @@ inline std::string getWKT(const std::vector<Polygon<T>>& ls) {
// _____________________________________________________________________________
template <typename T>
inline double len(const Point<T>& g) {
UNUSED(g);
return 0;
}
@ -772,24 +774,28 @@ inline double len(const Line<T>& g) {
// _____________________________________________________________________________
template <typename T>
inline Point<T> simplify(const Point<T>& g, double d) {
UNUSED(d);
return g;
}
// _____________________________________________________________________________
template <typename T>
inline LineSegment<T> simplify(const LineSegment<T>& g, double d) {
UNUSED(d);
return g;
}
// _____________________________________________________________________________
template <typename T>
inline Box<T> simplify(const Box<T>& g, double d) {
UNUSED(d);
return g;
}
// _____________________________________________________________________________
template <typename T>
inline RotatedBox<T> simplify(const RotatedBox<T>& g, double d) {
UNUSED(d);
return g;
}
@ -935,7 +941,7 @@ inline double parallelity(const Box<T>& box, const MultiLine<T>& multiline) {
}
// _____________________________________________________________________________
template <typename T, template <typename> typename Geometry>
template <template <typename> class Geometry, typename T>
inline RotatedBox<T> getOrientedEnvelope(Geometry<T> pol) {
// TODO: implement this nicer, works for now, but inefficient
// see
@ -1016,8 +1022,8 @@ inline Box<T> getBoundingBox(const Box<T>& b) {
}
// _____________________________________________________________________________
template <typename T, template <typename> typename GeometryA>
inline Box<T> getBoundingBox(const std::vector<GeometryA<T>>& multigeo) {
template <template <typename> class Geometry, typename T>
inline Box<T> getBoundingBox(const std::vector<Geometry<T>>& multigeo) {
Box<T> b;
b = extendBox(multigeo, b);
return b;
@ -1115,7 +1121,7 @@ inline Box<T> extendBox(const LineSegment<T>& ls, Box<T> b) {
}
// _____________________________________________________________________________
template <typename T, template <typename> typename Geometry>
template <template <typename> class Geometry, typename T>
inline Box<T> extendBox(const std::vector<Geometry<T>>& multigeom, Box<T> b) {
for (const auto& g : multigeom) b = extendBox(g, b);
return b;
@ -1176,7 +1182,7 @@ inline double commonArea(const Box<T>& ba, const Box<T>& bb) {
}
// _____________________________________________________________________________
template <typename T, template <typename> typename Geometry>
template <template <typename> class Geometry, typename T>
inline RotatedBox<T> getFullEnvelope(Geometry<T> pol) {
Point<T> center = centroid(pol);
Box<T> tmpBox = getBoundingBox(pol);

View file

@ -18,7 +18,7 @@ class GridException : public std::runtime_error {
GridException(std::string const& msg) : std::runtime_error(msg) {}
};
template <typename V, template <typename> typename G, typename T>
template <typename V, template <typename> class G, typename T>
class Grid {
public:
// initialization of a point grid with cell width w and cell height h

View file

@ -3,7 +3,7 @@
// Author: Patrick Brosi <brosip@informatik.uni-freiburg.de>
// _____________________________________________________________________________
template <typename V, template <typename> typename G, typename T>
template <typename V, template <typename> class G, typename T>
Grid<V, G, T>::Grid(bool bldIdx)
: _width(0),
_height(0),
@ -14,16 +14,16 @@ Grid<V, G, T>::Grid(bool bldIdx)
_hasValIdx(bldIdx) {}
// _____________________________________________________________________________
template <typename V, template <typename> typename G, typename T>
template <typename V, template <typename> class G, typename T>
Grid<V, G, T>::Grid() : Grid<V, G, T>(true) {}
// _____________________________________________________________________________
template <typename V, template <typename> typename G, typename T>
template <typename V, template <typename> class G, typename T>
Grid<V, G, T>::Grid(double w, double h, const Box<T>& bbox)
: Grid<V, G, T>(w, h, bbox, true) {}
// _____________________________________________________________________________
template <typename V, template <typename> typename G, typename T>
template <typename V, template <typename> class G, typename T>
Grid<V, G, T>::Grid(double w, double h, const Box<T>& bbox, bool bValIdx)
: _cellWidth(fabs(w)),
_cellHeight(fabs(h)),
@ -55,7 +55,7 @@ Grid<V, G, T>::Grid(double w, double h, const Box<T>& bbox, bool bValIdx)
}
// _____________________________________________________________________________
template <typename V, template <typename> typename G, typename T>
template <typename V, template <typename> class G, typename T>
void Grid<V, G, T>::add(G<T> geom, V val) {
Box<T> box = getBoundingBox(geom);
size_t swX = getCellXFromX(box.getLowerLeft().getX());
@ -74,14 +74,14 @@ void Grid<V, G, T>::add(G<T> geom, V val) {
}
// _____________________________________________________________________________
template <typename V, template <typename> typename G, typename T>
template <typename V, template <typename> class G, typename T>
void Grid<V, G, T>::add(size_t x, size_t y, V val) {
_grid[x][y].insert(val);
if (_hasValIdx) _index[val].insert(std::pair<size_t, size_t>(x, y));
}
// _____________________________________________________________________________
template <typename V, template <typename> typename G, typename T>
template <typename V, template <typename> class G, typename T>
void Grid<V, G, T>::get(const Box<T>& box, std::set<V>* s) const {
size_t swX = getCellXFromX(box.getLowerLeft().getX());
size_t swY = getCellYFromY(box.getLowerLeft().getY());
@ -94,7 +94,7 @@ void Grid<V, G, T>::get(const Box<T>& box, std::set<V>* s) const {
}
// _____________________________________________________________________________
template <typename V, template <typename> typename G, typename T>
template <typename V, template <typename> class G, typename T>
void Grid<V, G, T>::get(const G<T>& geom, double d, std::set<V>* s) const {
Box<T> a = getBoundingBox(geom);
Box<T> b(Point<T>(a.getLowerLeft().getX() - d,
@ -105,7 +105,7 @@ void Grid<V, G, T>::get(const G<T>& geom, double d, std::set<V>* s) const {
}
// _____________________________________________________________________________
template <typename V, template <typename> typename G, typename T>
template <typename V, template <typename> class G, typename T>
void Grid<V, G, T>::get(size_t x, size_t y, std::set<V>* s) const {
if (_hasValIdx) {
s->insert(_grid[x][y].begin(), _grid[x][y].end());
@ -119,7 +119,7 @@ void Grid<V, G, T>::get(size_t x, size_t y, std::set<V>* s) const {
}
// _____________________________________________________________________________
template <typename V, template <typename> typename G, typename T>
template <typename V, template <typename> class G, typename T>
void Grid<V, G, T>::remove(V val) {
if (_hasValIdx) {
auto i = _index.find(val);
@ -137,7 +137,7 @@ void Grid<V, G, T>::remove(V val) {
}
// _____________________________________________________________________________
template <typename V, template <typename> typename G, typename T>
template <typename V, template <typename> class G, typename T>
void Grid<V, G, T>::getNeighbors(const V& val, double d, std::set<V>* s) const {
if (!_hasValIdx) throw GridException("No value index build!");
auto it = _index.find(val);
@ -152,7 +152,7 @@ void Grid<V, G, T>::getNeighbors(const V& val, double d, std::set<V>* s) const {
}
// _____________________________________________________________________________
template <typename V, template <typename> typename G, typename T>
template <typename V, template <typename> class G, typename T>
void Grid<V, G, T>::getCellNeighbors(const V& val, size_t d,
std::set<V>* s) const {
if (!_hasValIdx) throw GridException("No value index build!");
@ -165,7 +165,7 @@ void Grid<V, G, T>::getCellNeighbors(const V& val, size_t d,
}
// _____________________________________________________________________________
template <typename V, template <typename> typename G, typename T>
template <typename V, template <typename> class G, typename T>
void Grid<V, G, T>::getCellNeighbors(size_t cx, size_t cy, size_t xPerm,
size_t yPerm, std::set<V>* s) const {
size_t swX = xPerm > cx ? 0 : cx - xPerm;
@ -182,7 +182,7 @@ void Grid<V, G, T>::getCellNeighbors(size_t cx, size_t cy, size_t xPerm,
}
// _____________________________________________________________________________
template <typename V, template <typename> typename G, typename T>
template <typename V, template <typename> class G, typename T>
std::set<std::pair<size_t, size_t> > Grid<V, G, T>::getCells(
const V& val) const {
if (!_hasValIdx) throw GridException("No value index build!");
@ -190,7 +190,7 @@ std::set<std::pair<size_t, size_t> > Grid<V, G, T>::getCells(
}
// _____________________________________________________________________________
template <typename V, template <typename> typename G, typename T>
template <typename V, template <typename> class G, typename T>
Box<T> Grid<V, G, T>::getBox(size_t x, size_t y) const {
Point<T> sw(_bb.getLowerLeft().getX() + x * _cellWidth,
_bb.getLowerLeft().getY() + y * _cellHeight);
@ -200,7 +200,7 @@ Box<T> Grid<V, G, T>::getBox(size_t x, size_t y) const {
}
// _____________________________________________________________________________
template <typename V, template <typename> typename G, typename T>
template <typename V, template <typename> class G, typename T>
size_t Grid<V, G, T>::getCellXFromX(double x) const {
float dist = x - _bb.getLowerLeft().getX();
if (dist < 0) dist = 0;
@ -208,7 +208,7 @@ size_t Grid<V, G, T>::getCellXFromX(double x) const {
}
// _____________________________________________________________________________
template <typename V, template <typename> typename G, typename T>
template <typename V, template <typename> class G, typename T>
size_t Grid<V, G, T>::getCellYFromY(double y) const {
float dist = y - _bb.getLowerLeft().getY();
if (dist < 0) dist = 0;
@ -216,13 +216,13 @@ size_t Grid<V, G, T>::getCellYFromY(double y) const {
}
// _____________________________________________________________________________
template <typename V, template <typename> typename G, typename T>
template <typename V, template <typename> class G, typename T>
size_t Grid<V, G, T>::getXWidth() const {
return _xWidth;
}
// _____________________________________________________________________________
template <typename V, template <typename> typename G, typename T>
template <typename V, template <typename> class G, typename T>
size_t Grid<V, G, T>::getYHeight() const {
return _yHeight;
}