Commits (3)
...@@ -21,10 +21,6 @@ ...@@ -21,10 +21,6 @@
#include <boost/graph/breadth_first_search.hpp> #include <boost/graph/breadth_first_search.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp> #include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/python/object.hpp>
#include <boost/python/list.hpp>
#include <boost/python/extract.hpp>
#include "histogram.hh" #include "histogram.hh"
#include "hash_map_wrap.hh" #include "hash_map_wrap.hh"
......
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
#include "graph_avg_correlations.hh" #include "graph_avg_correlations.hh"
#include <iostream>
using namespace std; using namespace std;
using namespace boost; using namespace boost;
using namespace graph_tool; using namespace graph_tool;
......
...@@ -21,12 +21,8 @@ ...@@ -21,12 +21,8 @@
#include <algorithm> #include <algorithm>
#include <boost/numeric/conversion/bounds.hpp> #include <boost/numeric/conversion/bounds.hpp>
#include <boost/numeric/conversion/cast.hpp> #include <boost/numeric/conversion/cast.hpp>
#include <boost/python/object.hpp>
#include <boost/python/list.hpp>
#include <boost/python/extract.hpp>
#include "histogram.hh" #include "histogram.hh"
#include "numpy_bind.hh" #include "numpy_bind.hh"
#include "shared_map.hh"
namespace graph_tool namespace graph_tool
{ {
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "graph_filtering.hh" #include "graph_filtering.hh"
#include <boost/python.hpp> #include <boost/python.hpp>
#include <boost/utility/enable_if.hpp>
#include "graph_selectors.hh" #include "graph_selectors.hh"
#include "graph_properties.hh" #include "graph_properties.hh"
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "graph_selectors.hh" #include "graph_selectors.hh"
#include "graph_properties.hh" #include "graph_properties.hh"
#include <boost/mpl/quote.hpp>
#include <boost/graph/breadth_first_search.hpp> #include <boost/graph/breadth_first_search.hpp>
#include <cmath> #include <cmath>
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "graph.hh" #include "graph.hh"
#include "graph_filtering.hh" #include "graph_filtering.hh"
#include "graph_util.hh" #include "graph_util.hh"
#include "graph_python_interface.hh"
#ifdef _OPENMP #ifdef _OPENMP
#include <omp.h> #include <omp.h>
#endif #endif
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "graph_selectors.hh" #include "graph_selectors.hh"
#include "graph_properties.hh" #include "graph_properties.hh"
#include <boost/bind/placeholders.hpp>
#include <boost/mpl/push_back.hpp> #include <boost/mpl/push_back.hpp>
#include <boost/python.hpp> #include <boost/python.hpp>
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "graph_selectors.hh" #include "graph_selectors.hh"
#include "graph_properties.hh" #include "graph_properties.hh"
#include <boost/bind/placeholders.hpp>
#include <boost/mpl/push_back.hpp> #include <boost/mpl/push_back.hpp>
#include <boost/python.hpp> #include <boost/python.hpp>
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "graph_selectors.hh" #include "graph_selectors.hh"
#include "graph_properties.hh" #include "graph_properties.hh"
#include <boost/bind/placeholders.hpp>
#include <boost/mpl/push_back.hpp> #include <boost/mpl/push_back.hpp>
#include <boost/python.hpp> #include <boost/python.hpp>
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "graph_selectors.hh" #include "graph_selectors.hh"
#include "graph_properties.hh" #include "graph_properties.hh"
#include <boost/bind/placeholders.hpp>
#include <boost/mpl/push_back.hpp> #include <boost/mpl/push_back.hpp>
#include <boost/python.hpp> #include <boost/python.hpp>
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "graph_selectors.hh" #include "graph_selectors.hh"
#include "graph_properties.hh" #include "graph_properties.hh"
#include <boost/bind/placeholders.hpp>
#include <boost/mpl/push_back.hpp> #include <boost/mpl/push_back.hpp>
#include <boost/python.hpp> #include <boost/python.hpp>
......
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#include <tuple> #include <tuple>
#include <iostream> #include <iostream>
#include <boost/functional/hash.hpp>
#include <boost/multi_array.hpp>
#include "graph.hh" #include "graph.hh"
#include "graph_filtering.hh" #include "graph_filtering.hh"
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#include "graph_union.hh" #include "graph_union.hh"
#include <boost/python/extract.hpp>
using namespace graph_tool; using namespace graph_tool;
using namespace boost; using namespace boost;
......
...@@ -20,9 +20,6 @@ ...@@ -20,9 +20,6 @@
#include "graph_union.hh" #include "graph_union.hh"
#include <boost/python/extract.hpp>
using namespace graph_tool; using namespace graph_tool;
using namespace boost; using namespace boost;
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include <boost/variant/get.hpp> #include <boost/variant/get.hpp>
#include <boost/spirit/include/support_istream_iterator.hpp> #include <boost/spirit/include/support_istream_iterator.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/type_traits.hpp>
#include <boost/algorithm/string/replace.hpp> #include <boost/algorithm/string/replace.hpp>
...@@ -44,7 +43,6 @@ ...@@ -44,7 +43,6 @@
#include <fstream> #include <fstream>
#include <string> #include <string>
#include <vector> #include <vector>
#include <unordered_map> #include <unordered_map>
#include "base64.hh" #include "base64.hh"
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include <boost/lambda/lambda.hpp> #include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp> #include <boost/lambda/bind.hpp>
#include <iostream>
using namespace std; using namespace std;
using namespace boost; using namespace boost;
......
...@@ -19,11 +19,11 @@ ...@@ -19,11 +19,11 @@
#define GRAPH_HH #define GRAPH_HH
#include "config.h" #include "config.h"
#include <Python.h>
#include <boost/python/object.hpp> #include <boost/python/object.hpp>
#include <boost/python/dict.hpp> #include <boost/python/list.hpp>
#include <boost/python/tuple.hpp>
#include <deque> #include <boost/any.hpp>
#include "graph_adjacency.hh" #include "graph_adjacency.hh"
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include "fast_vector_property_map.hh" #include "fast_vector_property_map.hh"
#include <boost/variant.hpp> #include <boost/variant.hpp>
#include <boost/mpl/vector.hpp> #include <boost/mpl/bool_fwd.hpp>
#include "graph_properties.hh" #include "graph_properties.hh"
#include "graph_exceptions.hh" #include "graph_exceptions.hh"
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include <deque> #include <deque>
#include <utility> #include <utility>
#include <numeric> #include <numeric>
#include <iostream>
#include <tuple> #include <tuple>
#include <boost/iterator.hpp> #include <boost/iterator.hpp>
#include <boost/graph/graph_traits.hpp> #include <boost/graph/graph_traits.hpp>
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "graph_selectors.hh" #include "graph_selectors.hh"
#include <boost/mpl/for_each.hpp> #include <boost/mpl/for_each.hpp>
#include <boost/mpl/contains.hpp>
#include <boost/python/extract.hpp> #include <boost/python/extract.hpp>
using namespace std; using namespace std;
......
...@@ -22,31 +22,14 @@ ...@@ -22,31 +22,14 @@
#include <boost/version.hpp> #include <boost/version.hpp>
#include <boost/graph/graph_traits.hpp> #include <boost/graph/graph_traits.hpp>
#include <boost/mpl/vector.hpp> #include <boost/mpl/vector.hpp>
#include <boost/mpl/erase.hpp>
#include <boost/mpl/clear.hpp>
#include <boost/mpl/map.hpp>
#include <boost/mpl/for_each.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/or.hpp>
#include <boost/mpl/if.hpp> #include <boost/mpl/if.hpp>
#include <boost/mpl/logical.hpp> #include <boost/mpl/logical.hpp>
#include <boost/mpl/inserter.hpp> #include <boost/mpl/back_inserter.hpp>
#include <boost/mpl/insert_range.hpp>
#include <boost/mpl/assert.hpp> #include <boost/mpl/assert.hpp>
#include <boost/mpl/plus.hpp>
#include <boost/mpl/divides.hpp>
#include <boost/mpl/arithmetic.hpp>
#include <boost/mpl/greater_equal.hpp>
#include <boost/mpl/comparison.hpp>
#include <boost/mpl/transform_view.hpp>
#include <boost/mpl/quote.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/print.hpp>
#include "graph_adaptor.hh" #include "graph_adaptor.hh"
#include "graph_filtered.hh" #include "graph_filtered.hh"
#include "graph_reverse.hh" #include "graph_reverse.hh"
#include "graph_selectors.hh"
#include "graph_util.hh" #include "graph_util.hh"
#include "mpl_nested_loop.hh" #include "mpl_nested_loop.hh"
...@@ -440,9 +423,83 @@ struct action_wrap ...@@ -440,9 +423,83 @@ struct action_wrap
Action _a; Action _a;
}; };
// this takes a functor and type ranges and iterates through the type //
// combinations when called with boost::any parameters, and calls the correct // action_dispatch machinery
// function //
// a lightweight class for holding a list of types
template <class... T>
struct typelist {};
template <class... T>
constexpr auto to_typelist(std::tuple<T...>) -> typelist<T...>;
template <class Tuple>
using to_typelist_t = decltype(to_typelist(std::declval<Tuple>()));
// handling one typelist/value
// select a binding from the current list
template<class F, // function to bind
class... Ts, // current typelist
class... TRS, // remaining typelists
class Arg,
class... Args>
bool dispatch_loop(F f,
typelist<typelist<Ts...>, TRS...>,
Arg&& arg,
Args&&... args) // remaining args
{
using namespace boost::mpl;
// determine which one of the Ts we are looking at
// then recurse with the first argument of F bound accordingly
void *farg; // pointer to extracted value from boost::any
// we always will know what its type is
if constexpr (sizeof...(TRS) == 0)
{
// just one argument remains to be bound
return (
// iterate over types, trying each
((farg = boost::any_cast<Ts>(&arg))
? (f(*static_cast<Ts*>(farg)), true)
// try reference_wrapper instead
: ((farg = boost::any_cast<std::reference_wrapper<Ts>>(&arg))
? (f(static_cast<std::reference_wrapper<Ts>*>(farg)->get()), true)
: false)) || ...);
}
else
{
// helper function for setting up recursion
auto dl =
[f = std::move(f)](auto * a, // extracted value from boost::any
auto&&... args) // boost::any's yet to be processed
{
// create the new F with N-1 arguments
return dispatch_loop
([f = std::move(f), a](auto &&... fargs){
f(*a,
std::forward<decltype(fargs)>(fargs)...);
},
typelist<TRS...>{},
std::forward<decltype(args)>(args)...);
};
return (
((farg = boost::any_cast<Ts>(&arg))
? dl(static_cast<Ts*>(farg),
std::forward<Args>(args)...)
: ((farg = boost::any_cast<std::reference_wrapper<Ts>>(&arg))
? dl(&static_cast<std::reference_wrapper<Ts>*>(farg)->get(),
std::forward<Args>(args)...)
: false))
|| ...); // iterate over Ts...
}
}
// this takes a functor and type ranges, locates the correct combination
// from the boost::any parameters, and calls the correct function
template <class Action, class Wrap, class... TRS> template <class Action, class Wrap, class... TRS>
struct action_dispatch struct action_dispatch
{ {
...@@ -451,8 +508,11 @@ struct action_dispatch ...@@ -451,8 +508,11 @@ struct action_dispatch
template <class... Args> template <class... Args>
void operator()(Args&&... args) const void operator()(Args&&... args) const
{ {
bool found = using namespace boost::mpl;
boost::mpl::nested_for_each<TRS...>(_a, std::forward<Args>(args)...);
bool found = dispatch_loop(_a, typelist<to_typelist_t<to_tuple_t<TRS>>...>{},
std::forward<Args>(args)...);
if (!found) if (!found)
{ {
std::vector<const std::type_info*> args_t = {(&(args).type())...}; std::vector<const std::type_info*> args_t = {(&(args).type())...};
......