Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63994 - sandbox/geometry/boost/geometry/strategies/concepts
From: barend.gehrels_at_[hidden]
Date: 2010-07-13 15:59:31


Author: barendgehrels
Date: 2010-07-13 15:59:29 EDT (Tue, 13 Jul 2010)
New Revision: 63994
URL: http://svn.boost.org/trac/boost/changeset/63994

Log:
Removed redundant remove_const calls
Added function_types approach for simplify
Text files modified:
   sandbox/geometry/boost/geometry/strategies/concepts/distance_concept.hpp | 53 +++++++++---------------
   sandbox/geometry/boost/geometry/strategies/concepts/simplify_concept.hpp | 85 ++++++++++++++++++++++++++-------------
   2 files changed, 77 insertions(+), 61 deletions(-)

Modified: sandbox/geometry/boost/geometry/strategies/concepts/distance_concept.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/concepts/distance_concept.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/concepts/distance_concept.hpp 2010-07-13 15:59:29 EDT (Tue, 13 Jul 2010)
@@ -28,6 +28,7 @@
 namespace boost { namespace geometry { namespace concept
 {
 
+
 /*!
     \brief Checks strategy for point-segment-distance
     \ingroup distance
@@ -57,30 +58,24 @@
>::type base_index;
 
             // 1: inspect and define both arguments of apply
- typedef typename boost::remove_const
+ typedef typename boost::remove_reference
                 <
- typename boost::remove_reference
+ typename boost::mpl::at
                         <
- typename boost::mpl::at
- <
- parameter_types,
- base_index
- >::type
+ parameter_types,
+ base_index
>::type
>::type ptype1;
 
- typedef typename boost::remove_const
+ typedef typename boost::remove_reference
                 <
- typename boost::remove_reference
+ typename boost::mpl::at
                         <
- typename boost::mpl::at
+ parameter_types,
+ typename boost::mpl::plus
                                 <
- parameter_types,
- typename boost::mpl::plus
- <
- base_index,
- boost::mpl::int_<1>
- >::type
+ base_index,
+ boost::mpl::int_<1>
>::type
>::type
>::type ptype2;
@@ -190,30 +185,24 @@
>::type base_index;
 
             // 1: inspect and define both arguments of apply
- typedef typename boost::remove_const
+ typedef typename boost::remove_reference
                 <
- typename boost::remove_reference
+ typename boost::mpl::at
                         <
- typename boost::mpl::at
- <
- parameter_types,
- base_index
- >::type
+ parameter_types,
+ base_index
>::type
>::type ptype;
 
- typedef typename boost::remove_const
+ typedef typename boost::remove_reference
                 <
- typename boost::remove_reference
+ typename boost::mpl::at
                         <
- typename boost::mpl::at
+ parameter_types,
+ typename boost::mpl::plus
                                 <
- parameter_types,
- typename boost::mpl::plus
- <
- base_index,
- boost::mpl::int_<1>
- >::type
+ base_index,
+ boost::mpl::int_<1>
>::type
>::type
>::type sptype;

Modified: sandbox/geometry/boost/geometry/strategies/concepts/simplify_concept.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/concepts/simplify_concept.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/concepts/simplify_concept.hpp 2010-07-13 15:59:29 EDT (Tue, 13 Jul 2010)
@@ -28,41 +28,68 @@
 struct SimplifyStrategy
 {
 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
- private :
+private :
 
- // 1) must define distance_strategy_type,
- // defining point-segment distance strategy (to be checked)
- typedef typename Strategy::distance_strategy_type ds_type;
-
- BOOST_CONCEPT_ASSERT
- (
- (concept::PointSegmentDistanceStrategy<ds_type>)
- );
+ // 1) must define distance_strategy_type,
+ // defining point-segment distance strategy (to be checked)
+ typedef typename Strategy::distance_strategy_type ds_type;
 
- struct apply_checker
- {
- static void check()
- {
- Strategy *str;
- std::vector<typename ds_type::point_type> const* v1;
- std::vector<typename ds_type::point_type> * v2;
-
- // 2) must implement method apply with arguments
- // - Range
- // - OutputIterator
- // - floating point value
- str->apply(*v1, std::back_inserter(*v2), 1.0);
-
- boost::ignore_unused_variable_warning(str);
- }
- };
 
- public :
- BOOST_CONCEPT_USAGE(SimplifyStrategy)
+ struct checker
+ {
+ template <typename ApplyMethod>
+ static void apply(ApplyMethod const&)
         {
- apply_checker::check();
+ namespace ft = boost::function_types;
+ typedef typename ft::parameter_types
+ <
+ ApplyMethod
+ >::type parameter_types;
+
+ typedef typename boost::mpl::if_
+ <
+ ft::is_member_function_pointer<ApplyMethod>,
+ boost::mpl::int_<1>,
+ boost::mpl::int_<0>
+ >::type base_index;
+
+ // 1: inspect and define both arguments of apply
+ typedef typename boost::remove_reference
+ <
+ typename boost::mpl::at
+ <
+ parameter_types,
+ base_index
+ >::type
+ >::type point_type;
+
+
 
+ BOOST_CONCEPT_ASSERT
+ (
+ (concept::PointSegmentDistanceStrategy<ds_type>)
+ );
+
+ Strategy *str;
+ std::vector<point_type> const* v1;
+ std::vector<point_type> * v2;
+
+ // 2) must implement method apply with arguments
+ // - Range
+ // - OutputIterator
+ // - floating point value
+ str->apply(*v1, std::back_inserter(*v2), 1.0);
+
+ boost::ignore_unused_variable_warning(str);
         }
+ };
+
+public :
+ BOOST_CONCEPT_USAGE(SimplifyStrategy)
+ {
+ checker::apply(&ds_type::apply);
+
+ }
 #endif
 };
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk