/*============================================================================= 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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include struct X { operator char const*() const { return ""; } }; struct Y { operator char const*() const { return ""; } }; struct reject_all { template struct apply : boost::mpl::false_ {}; }; int main() { using namespace boost::fusion; using boost::mpl::int_; using boost::mpl::_; using boost::mpl::not_; using boost::mpl::less; using boost::mpl::vector_c; using boost::is_class; using boost::is_same; std::cout << tuple_open('['); std::cout << tuple_close(']'); std::cout << tuple_delimiter(", "); { typedef vector vector_type; X x; Y y; vector_type v(y, '@', 987654, x, true, 6.6); typedef filter_view > > filter_view_type; filter_view_type view(v); std::cout << view << std::endl; BOOST_TEST((view == make_vector('@', 987654, true, 6.6))); BOOST_STATIC_ASSERT(boost::fusion::result_of::size::value == 4); } //cschmidt: This is illegal C++. ADL instantiates less<_, int_<3> > - which //leads to compile errors. /*{ // $$$ JDG $$$ For some obscure reason, EDG based compilers // (e.g. comeau 4.3.3, intel) have problems with this. // vc7.1 and g++ are ok. The errors from comeau are useless. #ifndef __EDG_VERSION__ typedef vector_c vector_type; typedef filter_view > > filter_view_type; vector_type v; filter_view_type view(v); std::cout << view << std::endl; BOOST_TEST((view == make_vector(1, 2, 0, -1))); BOOST_STATIC_ASSERT(boost::fusion::result_of::size::value == 4); #endif }*/ { // Previous filtering out all values caused problems as begin was not equal to end // Picked up by Andreas Pokorny typedef vector vec; typedef filter_view filter_view_type; BOOST_MPL_ASSERT((boost::fusion::result_of::equal_to::type, boost::fusion::result_of::end::type>)); } { typedef map, pair > map_type; map_type m(make_pair(0), make_pair("Bond")); typedef filter_view > > filter_view_type; filter_view_type f(m); BOOST_MPL_ASSERT((boost::fusion::result_of::has_key::type)); BOOST_MPL_ASSERT_NOT((boost::fusion::result_of::has_key::type)); BOOST_MPL_ASSERT((is_same::type>::type, double>)); BOOST_MPL_ASSERT((is_same::type>::type, std::string>)); std::cout << deref_data(begin(f)) << std::endl; BOOST_TEST((deref_data(begin(f)) == "Bond")); } return boost::report_errors(); }