|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r78024 - in trunk: boost/graph libs/graph/test
From: jewillco_at_[hidden]
Date: 2012-04-16 14:44:37
Author: jewillco
Date: 2012-04-16 14:44:36 EDT (Mon, 16 Apr 2012)
New Revision: 78024
URL: http://svn.boost.org/trac/boost/changeset/78024
Log:
Added test for Boost.Parameter version of isomorphism; fixed bugs that found
Text files modified:
trunk/boost/graph/breadth_first_search.hpp | 3 +
trunk/boost/graph/depth_first_search.hpp | 3 +
trunk/boost/graph/isomorphism.hpp | 3 +
trunk/boost/graph/named_function_params.hpp | 42 +++++++++++++++++++++++++++++----------
trunk/libs/graph/test/isomorphism.cpp | 10 +++++---
5 files changed, 43 insertions(+), 18 deletions(-)
Modified: trunk/boost/graph/breadth_first_search.hpp
==============================================================================
--- trunk/boost/graph/breadth_first_search.hpp (original)
+++ trunk/boost/graph/breadth_first_search.hpp 2012-04-16 14:44:36 EDT (Mon, 16 Apr 2012)
@@ -373,9 +373,10 @@
namespace graph {
namespace detail {
- template <typename Graph, typename Source, typename ArgPack>
+ template <typename Graph, typename Source>
struct breadth_first_search_impl {
typedef void result_type;
+ template <typename ArgPack>
void operator()(const Graph& g, const Source& source, const ArgPack& arg_pack) {
using namespace boost::graph::keywords;
typename boost::graph_traits<Graph>::vertex_descriptor sources[1] = {source};
Modified: trunk/boost/graph/depth_first_search.hpp
==============================================================================
--- trunk/boost/graph/depth_first_search.hpp (original)
+++ trunk/boost/graph/depth_first_search.hpp 2012-04-16 14:44:36 EDT (Mon, 16 Apr 2012)
@@ -286,9 +286,10 @@
// Boost.Parameter named parameter variant
namespace graph {
namespace detail {
- template <typename Graph, typename ArgPack>
+ template <typename Graph>
struct depth_first_search_impl {
typedef void result_type;
+ template <typename ArgPack>
void operator()(const Graph& g, const ArgPack& arg_pack) const {
using namespace boost::graph::keywords;
boost::depth_first_search(g,
Modified: trunk/boost/graph/isomorphism.hpp
==============================================================================
--- trunk/boost/graph/isomorphism.hpp (original)
+++ trunk/boost/graph/isomorphism.hpp 2012-04-16 14:44:36 EDT (Mon, 16 Apr 2012)
@@ -491,9 +491,10 @@
namespace graph {
namespace detail {
- template <typename Graph1, typename Graph2, typename ArgPack>
+ template <typename Graph1, typename Graph2>
struct isomorphism_impl {
typedef bool result_type;
+ template <typename ArgPack>
bool operator()(const Graph1& g1, const Graph2& g2, const ArgPack& arg_pack) const {
using namespace boost::graph::keywords;
typedef typename boost::detail::override_const_property_result<ArgPack, tag::vertex_index1_map, boost::vertex_index_t, Graph1>::type index1_map_type;
Modified: trunk/boost/graph/named_function_params.hpp
==============================================================================
--- trunk/boost/graph/named_function_params.hpp (original)
+++ trunk/boost/graph/named_function_params.hpp 2012-04-16 14:44:36 EDT (Mon, 16 Apr 2012)
@@ -13,6 +13,7 @@
#include <functional>
#include <vector>
#include <boost/ref.hpp>
+#include <boost/utility/result_of.hpp>
#include <boost/preprocessor.hpp>
#include <boost/parameter/name.hpp>
#include <boost/parameter/binding.hpp>
@@ -464,12 +465,34 @@
>()(g, ap[t | 0]);
}
+ template <typename F> struct make_arg_pack_type;
+ template <> struct make_arg_pack_type<void()> {typedef boost::parameter::aux::empty_arg_list type;};
+ template <typename K, typename A>
+ struct make_arg_pack_type<void(K, A)> {
+ typedef boost::parameter::aux::tagged_argument<K, A> type;
+ };
+
+#define BOOST_GRAPH_OPENING_PART_OF_PAIR(z, i, n) boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<BOOST_PP_CAT(Keyword, BOOST_PP_SUB(n, i)), BOOST_PP_CAT(Arg, BOOST_PP_SUB(n, i))>,
+#define BOOST_GRAPH_MAKE_PAIR_PARAM(z, i, _) const boost::parameter::aux::tagged_argument<BOOST_PP_CAT(Keyword, i), BOOST_PP_CAT(Arg, i)>& BOOST_PP_CAT(kw, i)
+
+#define BOOST_GRAPH_MAKE_AP_TYPE_SPECIALIZATION(z, i, _) \
+ template <BOOST_PP_ENUM_PARAMS(i, typename Keyword), BOOST_PP_ENUM_PARAMS(i, typename Arg)> \
+ struct make_arg_pack_type<void(BOOST_PP_ENUM_PARAMS(i, Keyword), BOOST_PP_ENUM_PARAMS(i, Arg))> { \
+ typedef \
+ BOOST_PP_REPEAT(i, BOOST_GRAPH_OPENING_PART_OF_PAIR, BOOST_PP_DEC(i)) boost::parameter::aux::empty_arg_list BOOST_PP_REPEAT(i, > BOOST_PP_TUPLE_EAT(3), ~) \
+ type; \
+ };
+ BOOST_PP_REPEAT_FROM_TO(2, 11, BOOST_GRAPH_MAKE_AP_TYPE_SPECIALIZATION, ~)
+#undef BOOST_GRAPH_MAKE_AP_TYPE_SPECIALIZATION
+
#define BOOST_GRAPH_MAKE_FORWARDING_FUNCTION(name, nfixed, nnamed_max) \
/* Entry point for conversion from BGL-style named parameters */ \
template <BOOST_PP_ENUM_PARAMS(nfixed, typename Param) BOOST_PP_COMMA_IF(nfixed) typename ArgPack> \
- typename detail::BOOST_PP_CAT(name, _impl)<BOOST_PP_ENUM_PARAMS(nfixed, Param) BOOST_PP_COMMA_IF(nfixed) ArgPack>::result_type \
+ typename boost::result_of< \
+ detail::BOOST_PP_CAT(name, _impl)<BOOST_PP_ENUM_PARAMS(nfixed, Param)>(BOOST_PP_ENUM_PARAMS(nfixed, Param) BOOST_PP_COMMA_IF(nfixed) const ArgPack&) \
+ >::type \
BOOST_PP_CAT(name, _with_named_params)(BOOST_PP_ENUM_BINARY_PARAMS(nfixed, const Param, & param) BOOST_PP_COMMA_IF(nfixed) const ArgPack& arg_pack) { \
- return detail::BOOST_PP_CAT(name, _impl)<BOOST_PP_ENUM_PARAMS(nfixed, Param) BOOST_PP_COMMA_IF(nfixed) ArgPack>()(BOOST_PP_ENUM_PARAMS(nfixed, param) BOOST_PP_COMMA_IF(nfixed) arg_pack); \
+ return detail::BOOST_PP_CAT(name, _impl)<BOOST_PP_ENUM_PARAMS(nfixed, Param)>()(BOOST_PP_ENUM_PARAMS(nfixed, param) BOOST_PP_COMMA_IF(nfixed) arg_pack); \
} \
/* Individual functions taking Boost.Parameter-style keyword arguments */ \
BOOST_PP_REPEAT(BOOST_PP_INC(nnamed_max), BOOST_GRAPH_MAKE_FORWARDING_FUNCTION_ONE, (name)(nfixed))
@@ -479,21 +502,18 @@
#define BOOST_GRAPH_MAKE_FORWARDING_FUNCTION_ONEX(z, nnamed, name, nfixed) \
template <BOOST_PP_ENUM_PARAMS(nfixed, typename Param) BOOST_PP_ENUM_TRAILING_PARAMS(nnamed, typename Keyword) BOOST_PP_ENUM_TRAILING_PARAMS(nnamed, typename Arg)> \
- typename detail::BOOST_PP_CAT(name, _impl)<BOOST_GRAPH_TEMPLATE_ARGS_FOR_IMPL(nnamed, nfixed)>::result_type \
+ typename boost::result_of< \
+ detail::BOOST_PP_CAT(name, _impl)<BOOST_PP_ENUM_PARAMS(nfixed, Param)> \
+ (BOOST_PP_ENUM_PARAMS(nfixed, Param) BOOST_PP_COMMA_IF(nfixed) \
+ const typename boost::detail::make_arg_pack_type<void(BOOST_PP_ENUM_PARAMS(nnamed, Keyword) BOOST_PP_COMMA_IF(nnamed) BOOST_PP_ENUM_PARAMS(nnamed, Arg))>::type&) \
+ >::type \
name(BOOST_PP_ENUM_BINARY_PARAMS(nfixed, const Param, & param) \
BOOST_PP_ENUM_TRAILING(nnamed, BOOST_GRAPH_MAKE_PAIR_PARAM, ~)) { \
- return detail::BOOST_PP_CAT(name, _impl)<BOOST_GRAPH_TEMPLATE_ARGS_FOR_IMPL(nnamed, nfixed)>() \
+ return detail::BOOST_PP_CAT(name, _impl)<BOOST_PP_ENUM_PARAMS(nfixed, Param)>() \
(BOOST_PP_ENUM_PARAMS(nfixed, param), \
(boost::parameter::aux::empty_arg_list() BOOST_PP_ENUM_TRAILING_PARAMS(nnamed, kw))); \
}
-#define BOOST_GRAPH_TEMPLATE_ARGS_FOR_IMPL(nnamed, nfixed) \
- BOOST_PP_ENUM_PARAMS(nfixed, Param), \
- BOOST_PP_REPEAT(nnamed, BOOST_GRAPH_OPENING_PART_OF_PAIR, BOOST_PP_DEC(nnamed)) boost::parameter::aux::empty_arg_list BOOST_PP_REPEAT(nnamed, > BOOST_PP_TUPLE_EAT(3), ~)
-
-#define BOOST_GRAPH_OPENING_PART_OF_PAIR(z, i, n) boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<BOOST_PP_CAT(Keyword, BOOST_PP_SUB(n, i)), BOOST_PP_CAT(Arg, BOOST_PP_SUB(n, i))>,
-#define BOOST_GRAPH_MAKE_PAIR_PARAM(z, i, _) const boost::parameter::aux::tagged_argument<BOOST_PP_CAT(Keyword, i), BOOST_PP_CAT(Arg, i)>& BOOST_PP_CAT(kw, i)
-
}
namespace detail {
Modified: trunk/libs/graph/test/isomorphism.cpp
==============================================================================
--- trunk/libs/graph/test/isomorphism.cpp (original)
+++ trunk/libs/graph/test/isomorphism.cpp 2012-04-16 14:44:36 EDT (Mon, 16 Apr 2012)
@@ -95,6 +95,7 @@
void test_isomorphism2()
{
+ using namespace boost::graph::keywords;
typedef adjacency_list<vecS, vecS, bidirectionalS> graph1;
typedef adjacency_list<listS, listS, bidirectionalS,
property<vertex_index_t, int> > graph2;
@@ -115,8 +116,8 @@
bool isomorphism_correct;
clock_t start = clock();
- BOOST_CHECK(isomorphism_correct = isomorphism
- (g1, g2, isomorphism_map(make_assoc_property_map(mapping))));
+ BOOST_CHECK(isomorphism_correct = boost::graph::isomorphism
+ (g1, g2, _isomorphism_map = make_assoc_property_map(mapping)));
clock_t end = clock();
std::cout << "Elapsed time (clock cycles): " << (end - start) << std::endl;
@@ -152,6 +153,7 @@
void test_isomorphism(int n, double edge_probability)
{
+ using namespace boost::graph::keywords;
typedef adjacency_list<vecS, vecS, bidirectionalS> graph1;
typedef adjacency_list<listS, listS, bidirectionalS,
property<vertex_index_t, int> > graph2;
@@ -171,8 +173,8 @@
bool isomorphism_correct;
clock_t start = clock();
- BOOST_CHECK(isomorphism_correct = isomorphism
- (g1, g2, isomorphism_map(make_assoc_property_map(mapping))));
+ BOOST_CHECK(isomorphism_correct = boost::graph::isomorphism
+ (g1, g2, _isomorphism_map = make_assoc_property_map(mapping)));
clock_t end = clock();
std::cout << "Elapsed time (clock cycles): " << (end - start) << std::endl;
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