/////////////////////////////////////////////////////////////////////////////// // deduce_domain.hpp // // Copyright 2008 Eric Niebler. 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) // Avoid a compile-time check inside the deduce_domain code. #define BOOST_PROTO_ASSERT_VALID_DOMAIN(DOM) typedef DOM DOM ## _ #include #include #include #include namespace proto = boost::proto; using proto::_; struct D0 : proto::domain<> { }; struct D1 : proto::domain { }; struct D2 : proto::domain { }; struct D3 : proto::domain<> { }; struct DD0 : proto::domain { }; struct DD1 : proto::domain { }; struct DD2 : proto::domain { }; struct DD3 : proto::domain { }; struct DD4 : proto::domain { }; void test1() { using boost::is_same; //* BOOST_MPL_ASSERT((is_same::type, D0>)); BOOST_MPL_ASSERT((is_same::type, D0>)); BOOST_MPL_ASSERT((is_same::type, D0>)); BOOST_MPL_ASSERT((is_same::type, D0>)); BOOST_MPL_ASSERT((is_same::type, D0>)); BOOST_MPL_ASSERT((is_same::type, D0>)); BOOST_MPL_ASSERT((is_same::type, D0>)); BOOST_MPL_ASSERT((is_same::type, proto::default_domain>)); BOOST_MPL_ASSERT((is_same::type, D0>)); BOOST_MPL_ASSERT((is_same::type, D0>)); BOOST_MPL_ASSERT((is_same::type, D0>)); BOOST_MPL_ASSERT((is_same::type, D0>)); BOOST_MPL_ASSERT((is_same::type, D0>)); BOOST_MPL_ASSERT((is_same::type, D0>)); BOOST_MPL_ASSERT((is_same::type, DD0>)); BOOST_MPL_ASSERT((is_same::type, DD0>)); BOOST_MPL_ASSERT((is_same::type, DD0>)); BOOST_MPL_ASSERT((is_same::type, DD0>)); BOOST_MPL_ASSERT((is_same::type, DD0>)); BOOST_MPL_ASSERT((is_same::type, DD0>)); BOOST_MPL_ASSERT((is_same::type, D0>)); BOOST_MPL_ASSERT((is_same::type, D0>)); BOOST_MPL_ASSERT((is_same::type, D0>)); BOOST_MPL_ASSERT((is_same::type, D0>)); BOOST_MPL_ASSERT((is_same::type, D0>)); BOOST_MPL_ASSERT((is_same::type, D0>)); BOOST_MPL_ASSERT((is_same::type, D1>)); // Very tricky to get right BOOST_MPL_ASSERT((is_same::type, D0>)); BOOST_MPL_ASSERT((is_same::type, D0>)); BOOST_MPL_ASSERT((is_same::type, D0>)); BOOST_MPL_ASSERT((is_same::type, D0>)); BOOST_MPL_ASSERT((is_same::type, D0>)); BOOST_MPL_ASSERT((is_same::type, D0>)); BOOST_MPL_ASSERT((is_same::type, D1>)); BOOST_MPL_ASSERT((is_same::type, proto::detail::not_a_domain>)); BOOST_MPL_ASSERT((is_same::type, proto::detail::not_a_domain>)); BOOST_MPL_ASSERT((is_same::type, proto::detail::not_a_domain>)); BOOST_MPL_ASSERT((is_same::type, proto::detail::not_a_domain>)); BOOST_MPL_ASSERT((is_same::type, proto::detail::not_a_domain>)); BOOST_MPL_ASSERT((is_same::type, proto::detail::not_a_domain>)); BOOST_MPL_ASSERT((is_same::type, proto::detail::not_a_domain>)); BOOST_MPL_ASSERT((is_same::type, proto::detail::not_a_domain>)); BOOST_MPL_ASSERT((is_same::type, proto::detail::not_a_domain>)); BOOST_MPL_ASSERT((is_same::type, proto::detail::not_a_domain>)); BOOST_MPL_ASSERT((is_same::type, proto::detail::not_a_domain>)); BOOST_MPL_ASSERT((is_same::type, proto::detail::not_a_domain>)); BOOST_MPL_ASSERT((is_same::type, proto::detail::not_a_domain>)); BOOST_MPL_ASSERT((is_same::type, proto::detail::not_a_domain>)); BOOST_MPL_ASSERT((is_same::type, proto::detail::not_a_domain>)); // These should be ambiguous. BOOST_MPL_ASSERT((is_same::type, proto::detail::not_a_domain>)); BOOST_MPL_ASSERT((is_same::type, proto::detail::not_a_domain>)); BOOST_MPL_ASSERT((is_same::type, proto::detail::not_a_domain>)); BOOST_MPL_ASSERT((is_same::type, DD2>)); BOOST_MPL_ASSERT((is_same::type, DD2>)); BOOST_MPL_ASSERT((is_same::type, DD2>)); BOOST_MPL_ASSERT((is_same::type, DD2>)); BOOST_MPL_ASSERT((is_same::type, DD2>)); BOOST_MPL_ASSERT((is_same::type, DD2>)); //*/ } using namespace boost::unit_test; /////////////////////////////////////////////////////////////////////////////// // init_unit_test_suite // test_suite* init_unit_test_suite( int argc, char* argv[] ) { test_suite *test = BOOST_TEST_SUITE("test deducing domains from sub-domains"); test->add(BOOST_TEST_CASE(&test1)); return test; }