From d51ba76e2020a30375640de742f5d394e98c7014 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Sun, 14 Oct 2018 13:40:56 +0100 Subject: [PATCH] Include examples in tests - Fix C++17 build errors in examples. Disable some examples that use Unix-ism's from building on other platforms. --- example/Jamfile.v2 | 5 +++-- example/astar_maze.cpp | 4 +++- example/fibonacci_heap.cpp | 4 ++++ example/gerdemann.cpp | 6 ++++-- example/knights_tour.cpp | 1 + example/last-mod-time.cpp | 1 + example/ordered_out_edges.cpp | 4 +++- test/Jamfile.v2 | 2 ++ 8 files changed, 21 insertions(+), 6 deletions(-) diff --git a/example/Jamfile.v2 b/example/Jamfile.v2 index 4ad34893..23444d71 100644 --- a/example/Jamfile.v2 +++ b/example/Jamfile.v2 @@ -3,6 +3,7 @@ # Distributed under the Boost Software License, Version 1.0. (See accompanying # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +import ../../config/checks/config : requires ; exe accum-compile-times : accum-compile-times.cpp ; exe actor_clustering : actor_clustering.cpp ; @@ -10,7 +11,7 @@ exe adjacency_list : adjacency_list.cpp ; exe adjacency_list_io : adjacency_list_io.cpp ; exe adjacency_matrix : adjacency_matrix.cpp ; exe adj_list_ra_edgelist : adj_list_ra_edgelist.cpp ; -exe astar-cities : astar-cities.cpp ; +exe astar-cities : astar-cities.cpp : [ requires unistd_h ] ; exe astar_maze : astar_maze.cpp ; exe bellman-example : bellman-example.cpp ; exe bellman-ford-internet : bellman-ford-internet.cpp ; @@ -125,7 +126,7 @@ exe kruskal-example : kruskal-example.cpp ; # exe kruskal-telephone : kruskal-telephone.cpp ; exe kuratowski_subgraph : kuratowski_subgraph.cpp ; # exe labeled_graph : last-mod-time.cpp ; -exe last-mod-time : last-mod-time.cpp ; +exe last-mod-time : last-mod-time.cpp : [ requires unistd_h ] ; # These need LEDA: # exe leda-concept-check : leda-concept-check.cpp ; diff --git a/example/astar_maze.cpp b/example/astar_maze.cpp index fad2c208..22ee8e38 100644 --- a/example/astar_maze.cpp +++ b/example/astar_maze.cpp @@ -46,7 +46,9 @@ typedef boost::graph_traits::vertex_descriptor vertex_descriptor; typedef boost::graph_traits::vertices_size_type vertices_size_type; // A hash function for vertices. -struct vertex_hash:std::unary_function { +struct vertex_hash{ + typedef vertex_descriptor argument_type; + typedef std::size_t result_type; std::size_t operator()(vertex_descriptor const& u) const { std::size_t seed = 0; boost::hash_combine(seed, u[0]); diff --git a/example/fibonacci_heap.cpp b/example/fibonacci_heap.cpp index 3dbdc5c9..78684c06 100644 --- a/example/fibonacci_heap.cpp +++ b/example/fibonacci_heap.cpp @@ -35,7 +35,11 @@ main() for (int c = 0; c < w.size(); ++c) w[c] = c; +#ifndef BOOST_NO_CXX98_RANDOM_SHUFFLE std::random_shuffle(w.begin(), w.end()); +#else + std::shuffle(w.begin(), w.end(), gen); +#endif for (i = 0; i < N; ++i) Q.push(i); diff --git a/example/gerdemann.cpp b/example/gerdemann.cpp index ceb8a235..48755a95 100644 --- a/example/gerdemann.cpp +++ b/example/gerdemann.cpp @@ -63,9 +63,11 @@ void merge_vertex template struct order_by_name - : public std::binary_function { - bool operator()(const StoredEdge& e1, const StoredEdge& e2) const { + typedef StoredEdge first_argument_type; + typedef StoredEdge second_argument_type; + typedef bool result_type; + bool operator()(const StoredEdge& e1, const StoredEdge& e2) const { // Using std::pair operator< as an easy way to get lexicographical // compare over tuples. return std::make_pair(e1.get_target(), boost::get(boost::edge_name, e1)) diff --git a/example/knights_tour.cpp b/example/knights_tour.cpp index 048cbde4..e655b5c6 100644 --- a/example/knights_tour.cpp +++ b/example/knights_tour.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/example/last-mod-time.cpp b/example/last-mod-time.cpp index 4788dd72..f4aa179a 100644 --- a/example/last-mod-time.cpp +++ b/example/last-mod-time.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/example/ordered_out_edges.cpp b/example/ordered_out_edges.cpp index 5c45373a..5b08c182 100644 --- a/example/ordered_out_edges.cpp +++ b/example/ordered_out_edges.cpp @@ -32,8 +32,10 @@ template struct order_by_name - : public std::binary_function { + typedef StoredEdge first_argument_type; + typedef StoredEdge second_argument_type; + typedef bool result_type; bool operator()(const StoredEdge& e1, const StoredEdge& e2) const { // Order by target vertex, then by name. // std::pair's operator< does a nice job of implementing diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 82779402..d241344d 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -164,3 +164,5 @@ if $(LEDA) compile leda_graph_cc.cpp : $(leda-include) ; } + +build-project ../example ;