// is_instance_of_test.cpp -- The Boost Lambda Library ------------------ // // Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) // // 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) // // For more information, see www.boost.org // ----------------------------------------------------------------------- #include // see "Header Implementation Option" #include "boost/lambda/detail/is_instance_of.hpp" #include template struct A1 {}; template struct A2 {}; template struct A3 {}; template struct A4 {}; class B1 : public A1 {}; class B2 : public A2 {}; class B3 : public A3 {}; class B4 : public A4 {}; // classes that are convertible to classes that derive from A instances // This is not enough to make the test succeed class C1 { public: operator A1() { return A1(); } }; class C2 { public: operator B2() { return B2(); } }; class C3 { public: operator B3() { return B3(); } }; class C4 { public: operator B4() { return B4(); } }; // test that the result is really a constant // (in an alternative implementation, gcc 3.0.2. claimed that it was // a non-constant) template class X {}; // this should compile X::value> x; int test_main(int, char *[]) { using boost::lambda::is_instance_of_1; using boost::lambda::is_instance_of_2; using boost::lambda::is_instance_of_3; using boost::lambda::is_instance_of_4; BOOST_CHECK((is_instance_of_1::value == true)); BOOST_CHECK((is_instance_of_1, A1>::value == true)); BOOST_CHECK((is_instance_of_1::value == false)); BOOST_CHECK((is_instance_of_1::value == false)); BOOST_CHECK((is_instance_of_2::value == true)); BOOST_CHECK((is_instance_of_2, A2>::value == true)); BOOST_CHECK((is_instance_of_2::value == false)); BOOST_CHECK((is_instance_of_2::value == false)); BOOST_CHECK((is_instance_of_3::value == true)); BOOST_CHECK((is_instance_of_3, A3>::value == true)); BOOST_CHECK((is_instance_of_3::value == false)); BOOST_CHECK((is_instance_of_3::value == false)); BOOST_CHECK((is_instance_of_4::value == true)); BOOST_CHECK((is_instance_of_4, A4>::value == true)); BOOST_CHECK((is_instance_of_4::value == false)); BOOST_CHECK((is_instance_of_4::value == false)); return 0; }