From 244d11da3f7726574cd6de81b96721d1d1a2783a Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 3 Jul 2014 01:39:36 +0300 Subject: [PATCH 1/6] [strategies][length] make the default length result variant aware --- .../strategies/default_length_result.hpp | 65 +++++++++++++++---- 1 file changed, 54 insertions(+), 11 deletions(-) diff --git a/include/boost/geometry/strategies/default_length_result.hpp b/include/boost/geometry/strategies/default_length_result.hpp index 706941b9e..b88b66086 100644 --- a/include/boost/geometry/strategies/default_length_result.hpp +++ b/include/boost/geometry/strategies/default_length_result.hpp @@ -1,8 +1,13 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -14,14 +19,57 @@ #ifndef BOOST_GEOMETRY_STRATEGIES_DEFAULT_LENGTH_RESULT_HPP #define BOOST_GEOMETRY_STRATEGIES_DEFAULT_LENGTH_RESULT_HPP +#include #include + +#include #include +#include namespace boost { namespace geometry { + +namespace resolve_strategy { namespace result_of +{ + +template +struct length +{ + typedef typename select_most_precise + < + typename coordinate_type::type, + long double + >::type type; +}; + +template +struct length > +{ + typedef typename compress_variant< + typename transform_variant< + boost::variant, + length + >::type + >::type type; +}; + +}} // namespace resolve_strategy::result_of + + +namespace resolve_variant { namespace result_of +{ + +template +struct length + : resolve_strategy::result_of::length +{}; + +}} // namespace resolve_variant::result_of + + /*! \brief Meta-function defining return type of length function \ingroup length @@ -32,15 +80,10 @@ namespace boost { namespace geometry */ template struct default_length_result -{ - typedef typename select_most_precise - < - typename coordinate_type::type, - long double - >::type type; -}; + : resolve_variant::result_of::length +{}; + }} // namespace boost::geometry - #endif // BOOST_GEOMETRY_STRATEGIES_DEFAULT_LENGTH_RESULT_HPP From 28806c90953bd57d4660303a0c697e0fcf33e905 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 3 Jul 2014 01:40:08 +0300 Subject: [PATCH 2/6] [algorithms][length] change length return type to default_length_result<...>::type --- include/boost/geometry/algorithms/length.hpp | 46 ++++++++------------ 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/include/boost/geometry/algorithms/length.hpp b/include/boost/geometry/algorithms/length.hpp index 0517a7c25..d0e8073cb 100644 --- a/include/boost/geometry/algorithms/length.hpp +++ b/include/boost/geometry/algorithms/length.hpp @@ -1,8 +1,13 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -181,36 +186,21 @@ namespace resolve_variant { template struct length { - typedef typename default_length_result::type result_type; - template - static inline result_type apply(Geometry const& geometry, - Strategy const& strategy) + static inline typename result_of::length::type + apply(Geometry const& geometry, Strategy const& strategy) { return dispatch::length::apply(geometry, strategy); } }; template -struct length > +struct length > { - typedef typename mpl::fold< - typename mpl::transform< - typename variant::types, - default_length_result - >::type, - mpl::set0<>, - mpl::insert - >::type possible_result_types; - - typedef typename mpl::if_< - mpl::greater< - mpl::size, - mpl::int_<1> - >, - typename make_variant_over::type, - typename mpl::front::type - >::type result_type; + typedef typename result_of::length + < + boost::variant + >::type result_type; template struct visitor @@ -223,7 +213,7 @@ struct length > {} template - inline typename length::result_type + inline typename result_of::length::type operator()(Geometry const& geometry) const { return length::apply(geometry, m_strategy); @@ -255,7 +245,7 @@ struct length > \qbk{[length] [length_output]} */ template -inline typename resolve_variant::length::result_type +inline typename default_length_result::type length(Geometry const& geometry) { concept::check(); @@ -287,7 +277,7 @@ length(Geometry const& geometry) \qbk{[length_with_strategy] [length_with_strategy_output]} */ template -inline typename resolve_variant::length::result_type +inline typename default_length_result::type length(Geometry const& geometry, Strategy const& strategy) { concept::check(); From 4b013a12d3154899226c0a2aed38e8b8c33f3ac9 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 3 Jul 2014 01:41:19 +0300 Subject: [PATCH 3/6] [algorithms][perimeter] change perimeter return type to default_length_result<...>::type --- .../boost/geometry/algorithms/perimeter.hpp | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/include/boost/geometry/algorithms/perimeter.hpp b/include/boost/geometry/algorithms/perimeter.hpp index 27d80e97b..27bb0f97a 100644 --- a/include/boost/geometry/algorithms/perimeter.hpp +++ b/include/boost/geometry/algorithms/perimeter.hpp @@ -1,8 +1,13 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -30,8 +35,6 @@ #include #include #include -#include -#include namespace boost { namespace geometry { @@ -107,14 +110,14 @@ namespace resolve_strategy { struct perimeter { template - static inline typename default_length_result::type + static inline typename result_of::length::type apply(Geometry const& geometry, Strategy const& strategy) { return dispatch::perimeter::apply(geometry, strategy); } template - static inline typename default_length_result::type + static inline typename result_of::length::type apply(Geometry const& geometry, default_strategy) { typedef typename strategy::distance::services::default_strategy @@ -134,10 +137,8 @@ namespace resolve_variant { template struct perimeter { - typedef typename default_length_result::type result_type; - template - static inline result_type + static inline typename result_of::length::type apply(Geometry const& geometry, Strategy const& strategy) { concept::check(); @@ -148,12 +149,10 @@ struct perimeter template struct perimeter > { - typedef typename compress_variant< - typename transform_variant< - boost::variant, - default_length_result - >::type - >:: type result_type; + typedef typename result_of::length + < + boost::variant + >::type result_type; template struct visitor: boost::static_visitor @@ -163,7 +162,8 @@ struct perimeter > visitor(Strategy const& strategy): m_strategy(strategy) {} template - result_type operator()(Geometry const& geometry) const + typename result_of::length::type + operator()(Geometry const& geometry) const { return perimeter::apply(geometry, m_strategy); } @@ -193,7 +193,7 @@ struct perimeter > \qbk{[include reference/algorithms/perimeter.qbk]} */ template -inline typename resolve_variant::perimeter::result_type perimeter( +inline typename default_length_result::type perimeter( Geometry const& geometry) { // detail::throw_on_empty_input(geometry); @@ -215,7 +215,7 @@ inline typename resolve_variant::perimeter::result_type perimeter( \qbk{[include reference/algorithms/perimeter.qbk]} */ template -inline typename resolve_variant::perimeter::result_type perimeter( +inline typename default_length_result::type perimeter( Geometry const& geometry, Strategy const& strategy) { // detail::throw_on_empty_input(geometry); From 927cbc9f01b110cbd22c263824c5812e4e36eaed Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 10 Jul 2014 10:09:07 +0300 Subject: [PATCH 4/6] [strategies][length (result)] eliminate result_of namespaces --- .../strategies/default_length_result.hpp | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/include/boost/geometry/strategies/default_length_result.hpp b/include/boost/geometry/strategies/default_length_result.hpp index b88b66086..806e4284c 100644 --- a/include/boost/geometry/strategies/default_length_result.hpp +++ b/include/boost/geometry/strategies/default_length_result.hpp @@ -32,11 +32,11 @@ namespace boost { namespace geometry { -namespace resolve_strategy { namespace result_of +namespace resolve_strategy { template -struct length +struct default_length_result { typedef typename select_most_precise < @@ -45,29 +45,29 @@ struct length >::type type; }; +} // namespace resolve_strategy + + +namespace resolve_variant +{ + +template +struct default_length_result + : resolve_strategy::default_length_result +{}; + template -struct length > +struct default_length_result > { typedef typename compress_variant< typename transform_variant< boost::variant, - length + resolve_strategy::default_length_result >::type >::type type; }; -}} // namespace resolve_strategy::result_of - - -namespace resolve_variant { namespace result_of -{ - -template -struct length - : resolve_strategy::result_of::length -{}; - -}} // namespace resolve_variant::result_of +} // namespace resolve_variant /*! @@ -80,7 +80,7 @@ struct length */ template struct default_length_result - : resolve_variant::result_of::length + : resolve_variant::default_length_result {}; From dacff470ee1d4f9cd899ff1807a8bd4d8b748349 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 10 Jul 2014 10:09:46 +0300 Subject: [PATCH 5/6] [algorithms][length] replace result_of::length by default_length_result --- include/boost/geometry/algorithms/length.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/geometry/algorithms/length.hpp b/include/boost/geometry/algorithms/length.hpp index d0e8073cb..6cbec5303 100644 --- a/include/boost/geometry/algorithms/length.hpp +++ b/include/boost/geometry/algorithms/length.hpp @@ -187,7 +187,7 @@ template struct length { template - static inline typename result_of::length::type + static inline typename default_length_result::type apply(Geometry const& geometry, Strategy const& strategy) { return dispatch::length::apply(geometry, strategy); @@ -197,7 +197,7 @@ struct length template struct length > { - typedef typename result_of::length + typedef typename default_length_result < boost::variant >::type result_type; @@ -213,7 +213,7 @@ struct length > {} template - inline typename result_of::length::type + inline typename default_length_result::type operator()(Geometry const& geometry) const { return length::apply(geometry, m_strategy); From 5640586f39c550ad40068bd1287a03ea053ff5e1 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 10 Jul 2014 10:10:19 +0300 Subject: [PATCH 6/6] [algorithms][perimeter] replace result_of::length by default_length_result --- include/boost/geometry/algorithms/perimeter.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/boost/geometry/algorithms/perimeter.hpp b/include/boost/geometry/algorithms/perimeter.hpp index 27bb0f97a..0ec153c1f 100644 --- a/include/boost/geometry/algorithms/perimeter.hpp +++ b/include/boost/geometry/algorithms/perimeter.hpp @@ -110,14 +110,14 @@ namespace resolve_strategy { struct perimeter { template - static inline typename result_of::length::type + static inline typename default_length_result::type apply(Geometry const& geometry, Strategy const& strategy) { return dispatch::perimeter::apply(geometry, strategy); } template - static inline typename result_of::length::type + static inline typename default_length_result::type apply(Geometry const& geometry, default_strategy) { typedef typename strategy::distance::services::default_strategy @@ -138,7 +138,7 @@ template struct perimeter { template - static inline typename result_of::length::type + static inline typename default_length_result::type apply(Geometry const& geometry, Strategy const& strategy) { concept::check(); @@ -149,7 +149,7 @@ struct perimeter template struct perimeter > { - typedef typename result_of::length + typedef typename default_length_result < boost::variant >::type result_type; @@ -162,7 +162,7 @@ struct perimeter > visitor(Strategy const& strategy): m_strategy(strategy) {} template - typename result_of::length::type + typename default_length_result::type operator()(Geometry const& geometry) const { return perimeter::apply(geometry, m_strategy);