// Copyright (C) 2004 Arkadiy Vertleyb // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) #pragma message("including typeof.hpp...") #include #pragma message("done") #include #include #include #include #include #include #include "mpl/register.hpp" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() using namespace std; using namespace boost; template mpl::vector1 typeof_test_helper(mpl::vector1*); template struct typeof_test { enum {value = boost::is_same< BOOST_TYPEOF_TPL(typeof_test_helper(reinterpret_cast*>(0))), mpl::vector1 >::value }; }; #pragma message("modifiers...") BOOST_STATIC_ASSERT(typeof_test::value); BOOST_STATIC_ASSERT(typeof_test::value); BOOST_STATIC_ASSERT(typeof_test::value); BOOST_STATIC_ASSERT(typeof_test::value); BOOST_STATIC_ASSERT(typeof_test::value); BOOST_STATIC_ASSERT(typeof_test::value); BOOST_STATIC_ASSERT(typeof_test::value); BOOST_STATIC_ASSERT(typeof_test::value); BOOST_STATIC_ASSERT((typeof_test*>::value)); #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION BOOST_STATIC_ASSERT((typeof_test&>::value)); #endif BOOST_STATIC_ASSERT((typeof_test >::value)); BOOST_STATIC_ASSERT((typeof_test >::value)); #pragma message("started") struct x {}; BOOST_TYPEOF_REGISTER_TYPE(x) template struct with_integrals {}; BOOST_TYPEOF_REGISTER_TEMPLATE_X(with_integrals, (class) (char) (unsigned short) (int) (unsigned long) (bool) (bool) (signed char) (unsigned) ) #pragma message("integral...") BOOST_STATIC_ASSERT((typeof_test >::value)); BOOST_STATIC_ASSERT((typeof_test >::value)); #pragma message("namespace-level function pointers...") BOOST_STATIC_ASSERT(typeof_test::value); BOOST_STATIC_ASSERT(typeof_test::value); BOOST_STATIC_ASSERT(typeof_test::value); BOOST_STATIC_ASSERT(typeof_test::value); #ifdef BOOST_TYPEOF_COMPLIANT # pragma message("function references...") BOOST_STATIC_ASSERT(typeof_test::value); BOOST_STATIC_ASSERT(typeof_test::value); #endif//BOOST_TYPEOF_COMPLIANT #ifdef BOOST_TYPEOF_COMPLIANT # pragma message("function values...") BOOST_STATIC_ASSERT(typeof_test::value); BOOST_STATIC_ASSERT(typeof_test::value); #endif//BOOST_TYPEOF_COMPLIANT #pragma message("member functions...") BOOST_STATIC_ASSERT(typeof_test::value); BOOST_STATIC_ASSERT(typeof_test::value); BOOST_STATIC_ASSERT(typeof_test::value); BOOST_STATIC_ASSERT(typeof_test::value); BOOST_STATIC_ASSERT(typeof_test::value); BOOST_STATIC_ASSERT(typeof_test::value); BOOST_STATIC_ASSERT(typeof_test::value); #pragma message("data members...") BOOST_STATIC_ASSERT(typeof_test::value); #pragma message("Lvalue test...") void lvalue_typeof_test() { int n; const int cn = 0; int& rn = n; const int& rcn = cn; int f(); //const int cf(); int& rf(); const int& rcf(); BOOST_STATIC_ASSERT((boost::is_same::value)); BOOST_STATIC_ASSERT((boost::is_same::value)); BOOST_STATIC_ASSERT((boost::is_same::value)); BOOST_STATIC_ASSERT((boost::is_same::value)); BOOST_STATIC_ASSERT((boost::is_same::value)); BOOST_STATIC_ASSERT((boost::is_same::value)); BOOST_STATIC_ASSERT((boost::is_same::value)); //BOOST_STATIC_ASSERT((boost::is_same::value)); //BOOST_STATIC_ASSERT((boost::is_same::value)); //BOOST_STATIC_ASSERT((boost::is_same::value)); } #pragma message("Noncopyable...") BOOST_TYPEOF_REGISTER_TYPE(boost::noncopyable) const boost::noncopyable& noncopiable_test_helper(); struct noncopiable_test { void bar() { BOOST_AUTO(const& v, noncopiable_test_helper()); v; // to avoid warning } }; #pragma message("STL containers...") BOOST_STATIC_ASSERT(typeof_test::value); BOOST_STATIC_ASSERT(typeof_test >::value); BOOST_STATIC_ASSERT(typeof_test >::value); BOOST_STATIC_ASSERT(typeof_test >::value); BOOST_STATIC_ASSERT(typeof_test >::value); BOOST_STATIC_ASSERT(typeof_test >::value); BOOST_STATIC_ASSERT((typeof_test >::value)); BOOST_STATIC_ASSERT((typeof_test >::value)); BOOST_STATIC_ASSERT(typeof_test >::value); BOOST_STATIC_ASSERT(typeof_test >::value); BOOST_STATIC_ASSERT(typeof_test >::value); #pragma message("function objects...") BOOST_STATIC_ASSERT((typeof_test >::value)); BOOST_STATIC_ASSERT((typeof_test >::value)); BOOST_STATIC_ASSERT(typeof_test >::value); BOOST_STATIC_ASSERT(typeof_test >::value); BOOST_STATIC_ASSERT(typeof_test >::value); BOOST_STATIC_ASSERT(typeof_test >::value); BOOST_STATIC_ASSERT(typeof_test >::value); BOOST_STATIC_ASSERT(typeof_test >::value); BOOST_STATIC_ASSERT(typeof_test >::value); BOOST_STATIC_ASSERT(typeof_test >::value); BOOST_STATIC_ASSERT(typeof_test >::value); BOOST_STATIC_ASSERT(typeof_test >::value); BOOST_STATIC_ASSERT(typeof_test >::value); BOOST_STATIC_ASSERT(typeof_test >::value); BOOST_STATIC_ASSERT(typeof_test >::value); BOOST_STATIC_ASSERT(typeof_test >::value); BOOST_STATIC_ASSERT(typeof_test >::value); BOOST_STATIC_ASSERT(typeof_test > >::value); BOOST_STATIC_ASSERT(typeof_test > >::value); BOOST_STATIC_ASSERT(typeof_test > >::value); BOOST_STATIC_ASSERT(typeof_test > >::value); #pragma message("valarray...") BOOST_STATIC_ASSERT(typeof_test >::value); #pragma message("compiling integral param wrapper...") namespace test_integral { // Enum template parameter enum E{ONE, TWO, THREE}; template struct foo { BOOST_STATIC_CONSTANT(E,value=e); }; // dependent template parameter template struct bar {}; // multi-word template parameter template struct blah {}; } BOOST_TYPEOF_REGISTER_TEMPLATE_X(test_integral::foo, (BOOST_TYPEOF_INTEGRAL(test_integral::E)) ); BOOST_TYPEOF_REGISTER_TEMPLATE_X(test_integral::blah, (BOOST_TYPEOF_INTEGRAL(unsigned long int)) ); BOOST_TYPEOF_REGISTER_TEMPLATE_X(test_integral::bar, (class) (BOOST_TYPEOF_INTEGRAL(P0)) ); namespace test_integral { void test() { foo x; bar xx; blah<5> xxx; BOOST_AUTO(y, x); BOOST_AUTO(yy, xx); BOOST_AUTO(yyy, xxx); y; yy; yyy; } } #pragma message("ODR...") void odr_test() { void odr_test1(); void odr_test2(); odr_test1(); odr_test2(); } #pragma message("main()...") int main() { odr_test(); } #pragma message("done!")