/*============================================================================= Copyright (c) 2001-2011 Joel de Guzman Copyright (c) 2006 Dan Marsden 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) ==============================================================================*/ #include "./example_struct.hpp" #include "./example_struct_type.hpp" #include #include #include #include #include #include #include int main() { example::example_struct bert("bert", 99); using namespace boost::fusion; BOOST_MPL_ASSERT((traits::is_associative)); BOOST_MPL_ASSERT((traits::is_random_access)); BOOST_MPL_ASSERT((traits::is_sequence)); BOOST_TEST(deref(begin(bert)) == "bert"); BOOST_TEST(*next(begin(bert)) == 99); BOOST_TEST(*prior(end(bert)) == 99); BOOST_TEST(*advance_c<1>(begin(bert)) == 99); BOOST_TEST(*advance_c<-1>(end(bert)) == 99); BOOST_TEST(distance(begin(bert), end(bert)) == 2); typedef result_of::begin::type first; typedef result_of::next::type second; BOOST_MPL_ASSERT((boost::is_same::type, std::string>)); BOOST_MPL_ASSERT((boost::is_same::type, int>)); BOOST_TEST(begin(bert) != end(bert)); BOOST_TEST(advance_c<2>(begin(bert)) == end(const_cast(bert))); BOOST_TEST(at_c<0>(bert) == "bert"); BOOST_TEST(at_c<1>(bert) == 99); BOOST_TEST(at_key(bert) == "bert"); BOOST_TEST(at_key(bert) == 99); BOOST_TEST(has_key(bert)); BOOST_TEST(has_key(bert)); BOOST_TEST(!has_key(bert)); BOOST_MPL_ASSERT((boost::is_same::type, std::string>)); BOOST_MPL_ASSERT((boost::is_same::type, int>)); BOOST_MPL_ASSERT((boost::is_same::type, std::string>)); BOOST_MPL_ASSERT((boost::is_same::type, int>)); BOOST_TEST(deref_data(begin(bert)) == "bert"); BOOST_TEST(deref_data(next(begin(bert))) == 99); BOOST_TEST(size(bert) == 2); return boost::report_errors(); }