Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions include/mapbox/feature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,22 @@
#include <memory>
#include <unordered_map>

#include "mapbox/geometry/warning.hpp"
namespace mapbox {
namespace feature {

// comparator functors
struct equal_comp_shared_ptr
{

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
MAPBOX_GEOMETRY_DISABLE_WARNING_PUSH
MAPBOX_GEOMETRY_DISABLE_WARNING_FLOAT_EQUAL
template <typename T>
bool operator()(T const& lhs, T const& rhs) const
{
return lhs == rhs;
}
#pragma GCC diagnostic pop
MAPBOX_GEOMETRY_DISABLE_WARNING_POP

template <typename T>
bool operator()(std::shared_ptr<T> const& lhs, std::shared_ptr<T> const& rhs) const
Expand Down
8 changes: 5 additions & 3 deletions include/mapbox/geometry/point.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "warning.hpp"

namespace mapbox {
namespace geometry {

Expand All @@ -21,16 +23,16 @@ struct point
T y;
};

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
MAPBOX_GEOMETRY_DISABLE_WARNING_PUSH
MAPBOX_GEOMETRY_DISABLE_WARNING_FLOAT_EQUAL

template <typename T>
constexpr bool operator==(point<T> const& lhs, point<T> const& rhs)
{
return lhs.x == rhs.x && lhs.y == rhs.y;
}

#pragma GCC diagnostic pop
MAPBOX_GEOMETRY_DISABLE_WARNING_POP

template <typename T>
constexpr bool operator!=(point<T> const& lhs, point<T> const& rhs)
Expand Down
31 changes: 31 additions & 0 deletions include/mapbox/geometry/warning.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef GEOMETRY_WARNING_HPP
#define GEOMETRY_WARNING_HPP

#if defined(_MSC_VER)
#define MAPBOX_GEOMETRY_DISABLE_WARNING_PUSH __pragma(warning(push))
#define MAPBOX_GEOMETRY_DISABLE_WARNING_POP __pragma(warning(pop))
#define MAPBOX_GEOMETRY_DISABLE_WARNING(warningNumber) __pragma(warning(disable \
: warningNumber))

// add warnings to deactivate here
// example: #define DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER MAPBOX_GEOMETRY_DISABLE_WARNING(4100)
#define MAPBOX_GEOMETRY_DISABLE_WARNING_FLOAT_EQUAL //MAPBOX_GEOMETRY_DISABLE_WARNING(??)

#elif defined(__GNUC__) || defined(__clang__)
#define MAPBOX_GEOMETRY_DO_PRAGMA(X) _Pragma(#X)
#define MAPBOX_GEOMETRY_DISABLE_WARNING_PUSH MAPBOX_GEOMETRY_DO_PRAGMA(GCC diagnostic push)
#define MAPBOX_GEOMETRY_DISABLE_WARNING_POP MAPBOX_GEOMETRY_DO_PRAGMA(GCC diagnostic pop)
#define MAPBOX_GEOMETRY_DISABLE_WARNING(warningName) MAPBOX_GEOMETRY_DO_PRAGMA(GCC diagnostic ignored #warningName)
// add warnings to deactivate here
// example: #define DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER MAPBOX_GEOMETRY_DISABLE_WARNING(-Wunused-parameter)
// disable clang-format for the next line since the waring definition would be formatted.
// clang-format off
#define MAPBOX_GEOMETRY_DISABLE_WARNING_FLOAT_EQUAL MAPBOX_GEOMETRY_DISABLE_WARNING(-Wfloat-equal)
// clang-format on
#else
#define MAPBOX_GEOMETRY_DISABLE_WARNING_PUSH
#define MAPBOX_GEOMETRY_DISABLE_WARNING_POP
// add all of the above warnings here (will be used if unknown compiler)
#define MAPBOX_GEOMETRY_DISABLE_WARNING_FLOAT_EQUAL
#endif
#endif