Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76205 - trunk/libs/geometry/doc/src/docutils/tools/support_status
From: bruno.lalande_at_[hidden]
Date: 2011-12-27 18:14:16


Author: bruno.lalande
Date: 2011-12-27 18:14:14 EST (Tue, 27 Dec 2011)
New Revision: 76205
URL: http://svn.boost.org/trac/boost/changeset/76205

Log:
Made append handling less hacky, and factorized further.
Text files modified:
   trunk/libs/geometry/doc/src/docutils/tools/support_status/support_status.cpp | 55 +++++++++++++++++++--------------------
   1 files changed, 27 insertions(+), 28 deletions(-)

Modified: trunk/libs/geometry/doc/src/docutils/tools/support_status/support_status.cpp
==============================================================================
--- trunk/libs/geometry/doc/src/docutils/tools/support_status/support_status.cpp (original)
+++ trunk/libs/geometry/doc/src/docutils/tools/support_status/support_status.cpp 2011-12-27 18:14:14 EST (Tue, 27 Dec 2011)
@@ -1,4 +1,6 @@
 #include <iostream>
+#include <string>
+#include <vector>
 
 #include <boost/type_traits/is_base_of.hpp>
 #include <boost/mpl/for_each.hpp>
@@ -29,28 +31,24 @@
     box_type,
     ring_type,
     segment_type
-> types;
+> all_types;
 
-#define DECLARE_CHECK_1(algorithm) \
- template <typename G, typename> \
- struct check_##algorithm: boost::geometry::dispatch::algorithm<G, point_type> \
- {};
 
-#define DECLARE_CHECK_2(algorithm) \
+#define DECLARE_BINARY_ALGORITHM(algorithm) \
     template <typename G1, typename G2> \
- struct check_##algorithm: boost::geometry::dispatch::algorithm<G1, G2> \
+ struct algorithm: boost::geometry::dispatch::algorithm<G1, G2> \
     {};
 
-DECLARE_CHECK_1(append)
-DECLARE_CHECK_2(distance)
-DECLARE_CHECK_2(convert)
+DECLARE_BINARY_ALGORITHM(append)
+DECLARE_BINARY_ALGORITHM(distance)
+DECLARE_BINARY_ALGORITHM(convert)
 
 
-template <template <typename, typename> class Dispatcher, typename G1 = void>
-struct tester
+template <template <typename, typename> class Dispatcher, typename G2>
+struct do_test
 {
- template <typename G2>
- void operator()(G2)
+ template <typename G1>
+ void operator()(G1)
     {
         if (boost::is_base_of<boost::geometry::nyi::not_implemented_tag, Dispatcher<G1, G2> >::type::value)
         {
@@ -63,31 +61,32 @@
     }
 };
 
-template <template <typename, typename> class Dispatcher>
-struct tester<Dispatcher, void>
+template <template <typename, typename> class Dispatcher, typename Types>
+struct test
 {
- template <typename G>
- void operator()(G)
+ template <typename G2>
+ void operator()(G2)
     {
- boost::mpl::for_each<types>(tester<Dispatcher, G>());
+ boost::mpl::for_each<Types>(do_test<Dispatcher, G2>());
         std::cout << std::endl;
     }
 };
 
 
-int main()
+template<template <typename, typename> class Dispatcher, typename Types1, typename Types2>
+void test_binary_algorithm(const std::string& name)
 {
- std::cout << "APPEND" << std::endl;
- boost::mpl::for_each<boost::mpl::vector<int> >(tester<check_append>());
+ std::cout << name << std::endl;
+ boost::mpl::for_each<Types1>(test<Dispatcher, Types2>());
     std::cout << std::endl;
+}
 
- std::cout << "DISTANCE" << std::endl;
- boost::mpl::for_each<types>(tester<check_distance>());
- std::cout << std::endl;
 
- std::cout << "CONVERT" << std::endl;
- boost::mpl::for_each<types>(tester<check_convert>());
- std::cout << std::endl;
+int main()
+{
+ test_binary_algorithm<append, all_types, boost::mpl::vector<point_type, std::vector<point_type> > >("APPEND");
+ test_binary_algorithm<convert, all_types, all_types>("CONVERT");
+ test_binary_algorithm<distance, all_types, all_types>("DISTANCE");
 
     return 0;
 }


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