parameter/test/literate/predicate-requirements0.cpp
CromwellEnage 278a728906 Restructure tests.
<boost/parameter/parameters.hpp>:
* Add preprocessor conditional statement to prevent generation of ill-formed function call operator overloads.

"test/maybe.cpp"
"test/singular.cpp"
"test/tutorial.cpp"
"test/sfinae.cpp"
"test/earwicker.cpp"
* Replace BOOST_PARAMETER_KEYWORD statements with BOOST_PARAMETER_NAME statements.

"test/optional_deduced_sfinae.cpp"
"test/normalized_argument_types.cpp"
"test/literate/*.cpp"
* Use Boost.Core.LightweightTest where int main() is available.
* Replace assert statements with BOOST_TEST_EQ statements.

"test/basics.hpp"
* Remove preprocessor statements regarding borland, gcc-2, and msvc workarounds.

"test/ntp.cpp"
"test/sfinae.cpp"
"test/earwicker.cpp"
"test/normalized_argument_types.cpp"
"test/basics.hpp"
* Add preprocessor conditional statement to #error out if BOOST_PARAMETER_MAX_ARITY is set to an insufficient value.

"test/basics.cpp"
"test/deduced.cpp"
"test/macros.cpp"
"test/preprocessor.cpp"
"test/preprocessor_deduced.cpp"
* Replace S and char const* expressions with boost::container::string expressions.
* Uncomment any code that fails to compile, but add preprocessor conditional statement so that test suites can incorporate compile-fail statements regarding the code in question.
* Ensure that int main() returns boost::process_errors().

"test/literate/deduced-template-parameters0.cpp":
"test/literate/exercising-the-code-so-far0.cpp":
* Enclose BOOST_MPL_ASSERT statements within MPL_TEST_CASE block.

"test/literate/defining-the-keywords1.cpp":
* Add graphs::tag::graph::qualifier type definition because perfect forwarding code will check for it.
* Replace deprecated keyword::get() invocation with keyword::instance invocation.

test/Jamfile.v2:
* Add modifier <define>BOOST_PARAMETER_MAX_ARITY=# to run, run-fail, compile, and compile-fail statements to conserve compiler memory usage on GitHub's side.
* Add modifier <preserve-target-tests>off to run and run-fail statements to conserve executable space on GitHub's side.
* Separate bpl-test statement into its own target, parameter_python_test, which fails on xcode8.3 as well as on mingw and msvc compilers with address-model=64.
* The next commit (which will implement perfect forwarding) will subsume test/literate/Jamfile.v2 into this file.  Strangely enough, attempting to do so now will result in compiler errors.

.travis.yml:
* Add g++-4.7, g++-4.8, g++-4.9, clang++-3.5, clang++-3.6, clang++-3.7, clang++-3.8, clang++-3.9, clang++-4.0, xcode7.3, and xcode8.3 compiler configurations.
* Split compiler configurations by available CXXSTD values.  (This will keep the job times within limits for the next commit.)
* Ensure that the xcode8.3 compiler configurations exclude parameter_python_test from the test suite.

appveyor.yml:
* Add compiler configurations that support address-model=64 to the test matrix.
* Ensure that the new configurations exclude parameter_python_test from the test suite.
2018-10-28 13:13:07 -04:00

190 lines
4.9 KiB
C++

#include <boost/parameter.hpp>
BOOST_PARAMETER_NAME((_graph, graphs) graph)
BOOST_PARAMETER_NAME((_visitor, graphs) visitor)
BOOST_PARAMETER_NAME((_root_vertex, graphs) in(root_vertex))
BOOST_PARAMETER_NAME((_index_map, graphs) in(index_map))
BOOST_PARAMETER_NAME((_color_map, graphs) in_out(color_map))
#include <boost/graph/graph_traits.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_same.hpp>
struct vertex_descriptor_predicate
{
template <typename T, typename Args>
struct apply
: boost::mpl::if_<
boost::is_convertible<
T
, typename boost::graph_traits<
typename boost::parameter::value_type<
Args
, graphs::graph
>::type
>::vertex_descriptor
>
, boost::mpl::true_
, boost::mpl::false_
>
{
};
};
#include <boost/mpl/eval_if.hpp>
struct graph_predicate
{
template <typename T, typename Args>
struct apply
: boost::mpl::eval_if<
boost::is_convertible<
typename boost::graph_traits<T>::traversal_category
, boost::incidence_graph_tag
>
, boost::mpl::if_<
boost::is_convertible<
typename boost::graph_traits<T>::traversal_category
, boost::vertex_list_graph_tag
>
, boost::mpl::true_
, boost::mpl::false_
>
, boost::mpl::false_
>
{
};
};
#include <boost/property_map/property_map.hpp>
#include <boost/type_traits/is_same.hpp>
struct color_map_predicate
{
template <typename T, typename Args>
struct apply
: boost::mpl::if_<
boost::is_same<
typename boost::property_traits<T>::key_type
, typename boost::graph_traits<
typename boost::parameter::value_type<
Args
, graphs::graph
>::type
>::vertex_descriptor
>
, boost::mpl::true_
, boost::mpl::false_
>
{
};
};
#include <boost/type_traits/is_integral.hpp>
struct index_map_predicate
{
template <typename T, typename Args>
struct apply
: boost::mpl::eval_if<
boost::is_integral<
typename boost::property_traits<T>::value_type
>
, boost::mpl::if_<
boost::is_same<
typename boost::property_traits<T>::key_type
, typename boost::graph_traits<
typename boost::parameter::value_type<
Args
, graphs::graph
>::type
>::vertex_descriptor
>
, boost::mpl::true_
, boost::mpl::false_
>
, boost::mpl::false_
>
{
};
};
#include <boost/graph/properties.hpp>
#include <vector>
template <typename Size, typename IndexMap>
boost::iterator_property_map<
std::vector<boost::default_color_type>::iterator
, IndexMap
, boost::default_color_type
, boost::default_color_type&
>&
default_color_map(Size num_vertices, IndexMap const& index_map)
{
static std::vector<boost::default_color_type> colors(num_vertices);
static boost::iterator_property_map<
std::vector<boost::default_color_type>::iterator
, IndexMap
, boost::default_color_type
, boost::default_color_type&
> m(colors.begin(), index_map);
return m;
}
#include <boost/graph/depth_first_search.hpp>
BOOST_PARAMETER_FUNCTION((void), depth_first_search, graphs,
(required
(graph, *(graph_predicate))
)
(optional
(visitor
, * // not easily checkable
, boost::dfs_visitor<>()
)
(root_vertex
, *(vertex_descriptor_predicate)
, *vertices(graph).first
)
(index_map
, *(index_map_predicate)
, get(boost::vertex_index, graph)
)
(color_map
, *(color_map_predicate)
, default_color_map(num_vertices(graph), index_map)
)
)
)
{
}
#include <boost/core/lightweight_test.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <utility>
int main()
{
typedef boost::adjacency_list<
boost::vecS
, boost::vecS
, boost::directedS
> G;
enum {u, v, w, x, y, z, N};
typedef std::pair<std::size_t,std::size_t> E;
E edges[] = {
E(u, v), E(u, x), E(x, v), E(y, x),
E(v, y), E(w, y), E(w, z), E(z, z)
};
G g(edges, edges + sizeof(edges) / sizeof(E), N);
::depth_first_search(g);
::depth_first_search(g, _root_vertex = static_cast<std::size_t>(x));
return boost::report_errors();
}