/*============================================================================= Copyright (c) 2001-2011 Joel de Guzman 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 #include #include #include #include #include #include #include #include struct X { operator int() const { return 12345; } }; int main() { using namespace boost::fusion; using boost::mpl::identity; { typedef vector seq_type; seq_type seq(12345, 'x', 678910, 3.36); std::cout << *boost::fusion::find(seq) << std::endl; BOOST_TEST(*boost::fusion::find(seq) == 'x'); std::cout << *boost::fusion::find(seq) << std::endl; BOOST_TEST(*boost::fusion::find(seq) == 12345); std::cout << *boost::fusion::find(seq) << std::endl; BOOST_TEST(*boost::fusion::find(seq) == 3.36); BOOST_TEST(boost::fusion::find(seq) == boost::fusion::end(seq)); } { typedef set seq_type; seq_type seq(12345, 'x', 3.36); std::cout << *boost::fusion::find(seq) << std::endl; BOOST_TEST(*boost::fusion::find(seq) == 'x'); BOOST_TEST(boost::fusion::find(seq) == boost::fusion::end(seq)); } { typedef map< pair , pair > map_type; map_type seq( make_pair('X') , make_pair("Men")); std::cout << *boost::fusion::find(seq) << std::endl; std::cout << *boost::fusion::find(seq) << std::endl; BOOST_TEST((*boost::fusion::find(seq)).second == 'X'); BOOST_TEST((*boost::fusion::find(seq)).second == "Men"); BOOST_TEST(boost::fusion::find(seq) == boost::fusion::end(seq)); } { typedef boost::mpl::vector mpl_vec; BOOST_TEST((*boost::fusion::find(mpl_vec()) == 12345)); BOOST_TEST(boost::fusion::find(mpl_vec()) == boost::fusion::end(mpl_vec())); } return boost::report_errors(); }