2006-08-22 15:57:13 +00:00
|
|
|
/*=============================================================================
|
|
|
|
Copyright (c) 2001-2006 Joel de Guzman
|
|
|
|
|
2007-03-02 10:44:14 +00:00
|
|
|
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)
|
2006-08-22 15:57:13 +00:00
|
|
|
==============================================================================*/
|
|
|
|
#include <boost/detail/lightweight_test.hpp>
|
2007-10-20 11:49:17 +00:00
|
|
|
#include <boost/fusion/container/vector/vector.hpp>
|
|
|
|
#include <boost/fusion/adapted/mpl.hpp>
|
2006-08-22 15:57:13 +00:00
|
|
|
#include <boost/fusion/sequence/generation/make_vector.hpp>
|
|
|
|
#include <boost/fusion/sequence/generation/make_list.hpp>
|
|
|
|
#include <boost/fusion/sequence/conversion/as_set.hpp>
|
|
|
|
#include <boost/fusion/sequence/conversion/as_list.hpp>
|
|
|
|
#include <boost/fusion/sequence/conversion/as_vector.hpp>
|
|
|
|
#include <boost/fusion/algorithm/transformation/push_back.hpp>
|
|
|
|
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
|
|
|
#include <boost/fusion/sequence/intrinsic/at_key.hpp>
|
|
|
|
#include <boost/fusion/sequence/io/out.hpp>
|
|
|
|
#include <boost/mpl/vector_c.hpp>
|
|
|
|
|
|
|
|
int
|
|
|
|
main()
|
|
|
|
{
|
|
|
|
using namespace boost::fusion;
|
|
|
|
using namespace boost;
|
|
|
|
|
|
|
|
std::cout << tuple_open('[');
|
|
|
|
std::cout << tuple_close(']');
|
|
|
|
std::cout << tuple_delimiter(", ");
|
|
|
|
|
|
|
|
{
|
|
|
|
vector0 empty;
|
|
|
|
std::cout << as_set(make_list(1, 1.23, "harru")) << std::endl;
|
|
|
|
std::cout << as_set(push_back(empty, 999)) << std::endl;
|
|
|
|
|
|
|
|
BOOST_TEST(as_list(as_set(make_list(1, 1.23, "harru")))
|
|
|
|
== make_list(1, 1.23, std::string("harru")));
|
|
|
|
BOOST_TEST(as_list(as_set(push_back(empty, 999)))
|
|
|
|
== push_back(empty, 999));
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
result_of::as_set<list<int, double, std::string> >::type set(1, 1.23, "harru");
|
|
|
|
std::cout << at_key<int>(set) << std::endl;
|
|
|
|
BOOST_TEST(at_key<int>(set) == 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
std::cout << as_set(mpl::vector_c<int, 1, 2, 3, 4, 5>()) << std::endl;
|
|
|
|
BOOST_TEST((as_list(as_set(mpl::vector_c<int, 1, 2, 3, 4, 5>()))
|
|
|
|
== mpl::vector_c<int, 1, 2, 3, 4, 5>()));
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
// test conversion
|
|
|
|
set<int, std::string> s(make_vector(123, "harru"));
|
|
|
|
BOOST_TEST(as_vector(s) == make_vector(123, "harru"));
|
|
|
|
s = (make_vector(235, "hola")); // test assign
|
|
|
|
BOOST_TEST(as_vector(s) == make_vector(235, "hola"));
|
|
|
|
}
|
|
|
|
|
|
|
|
return boost::report_errors();
|
|
|
|
}
|
|
|
|
|