Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2011-02-01 01:30:16 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:11:34 +0300
commit541e1561f7ee7642431d07a4bf7b3420a0281fee (patch)
treeea04582684d8171943e71adeecc2c7324b288c34 /geometry/region2d.hpp
parent3c96bb7da6927b44c552b45181e8f0fb2656f75b (diff)
Minor code fix.
Diffstat (limited to 'geometry/region2d.hpp')
-rw-r--r--geometry/region2d.hpp34
1 files changed, 20 insertions, 14 deletions
diff --git a/geometry/region2d.hpp b/geometry/region2d.hpp
index 1c69202880..8a24cde225 100644
--- a/geometry/region2d.hpp
+++ b/geometry/region2d.hpp
@@ -11,11 +11,6 @@ namespace m2
{
namespace detail
{
- // Get a big type for storing middle calculations (x*y) to avoid overflow.
- template <int floating> struct BigType;
- template <> struct BigType<0> { typedef int64_t type; };
- template <> struct BigType<1> { typedef double type; };
-
struct DefEqualFloat
{
template <class PointT>
@@ -44,20 +39,31 @@ namespace m2
}
};
- template <int floating> struct EqualSelector;
- template <> struct EqualSelector<1> { typedef DefEqualFloat type; };
- template <> struct EqualSelector<0> { typedef DefEqualInt type; };
+ template <int floating> struct TraitsType;
+ template <> struct TraitsType<1>
+ {
+ typedef DefEqualFloat EqualType;
+ typedef double BigType;
+ };
+ template <> struct TraitsType<0>
+ {
+ typedef DefEqualInt EqualType;
+ typedef int64_t BigType;
+ };
}
template <class PointT>
class Region
- {
- typedef vector<PointT> internal_container;
-
+ {
public:
typedef PointT value_type;
typedef typename PointT::value_type coord_type;
+ private:
+ typedef vector<PointT> internal_container;
+ typedef detail::TraitsType<is_floating_point<coord_type>::value> traits_type;
+
+ public:
Region() {}
template <class TInputIterator>
@@ -107,7 +113,7 @@ namespace m2
size_t const numPoints = m_points.size();
- typedef typename detail::BigType<is_floating_point<coord_type>::value>::type BigCoordT;
+ typedef typename traits_type::BigType BigCoordT;
typedef Point<BigCoordT> BigPointT;
BigPointT prev = BigPointT(m_points[numPoints - 1]) - BigPointT(pt);
@@ -126,7 +132,7 @@ namespace m2
ASSERT_NOT_EQUAL ( curr.y, prev.y, () );
BigCoordT const delta = prev.y - curr.y;
- BigCoordT cp = CrossProduct(curr, prev);
+ BigCoordT const cp = CrossProduct(curr, prev);
if (!equalF.EqualZero(cp, delta))
{
@@ -153,7 +159,7 @@ namespace m2
bool Contains(PointT const & pt) const
{
- return Contains(pt, typename detail::EqualSelector<is_floating_point<coord_type>::value>::type());
+ return Contains(pt, typename traits_type::EqualType());
}
private: