// 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) #define BOOST_TYPEOF_TEXT "including typeof.hpp..." #include #include #define BOOST_TYPEOF_TEXT "done" #include #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 }; }; #ifdef BOOST_TYPEOF_COMPLIANT #define BOOST_TYPEOF_TEXT "template template encoding..." #include namespace template_template { template class P0,int P1> struct tt_test {}; template struct C {}; template class T> struct A; } BOOST_TYPEOF_REGISTER_TEMPLATE(template_template::A, (BOOST_TYPEOF_TEMPLATE(2))) BOOST_TYPEOF_REGISTER_TEMPLATE(template_template::tt_test, (BOOST_TYPEOF_TEMPLATE((typename)(unsigned int))) (int) ) BOOST_TYPEOF_REGISTER_TEMPLATE(template_template::C, (typename) (unsigned int) ) BOOST_STATIC_ASSERT((typeof_test >::value)); #endif #define BOOST_TYPEOF_TEXT "modifiers..." #include 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)); struct x {}; BOOST_TYPEOF_REGISTER_TYPE(x) template struct with_integrals {}; BOOST_TYPEOF_REGISTER_TEMPLATE(with_integrals, (class) (char) (unsigned short) (int) (unsigned long) (bool) (bool) (signed char) (unsigned) ) #define BOOST_TYPEOF_TEXT "integral..." #include BOOST_STATIC_ASSERT((typeof_test >::value)); BOOST_STATIC_ASSERT((typeof_test >::value)); #define BOOST_TYPEOF_TEXT "namespace-level function pointers..." #include 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 # define BOOST_TYPEOF_TEXT "function references..." # include BOOST_STATIC_ASSERT(typeof_test::value); BOOST_STATIC_ASSERT(typeof_test::value); #endif//BOOST_TYPEOF_COMPLIANT #ifdef BOOST_TYPEOF_COMPLIANT # define BOOST_TYPEOF_TEXT "function values..." # include BOOST_STATIC_ASSERT(typeof_test::value); BOOST_STATIC_ASSERT(typeof_test::value); #endif//BOOST_TYPEOF_COMPLIANT #define BOOST_TYPEOF_TEXT "member functions..." #include 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); #define BOOST_TYPEOF_TEXT "data members..." #include BOOST_STATIC_ASSERT(typeof_test::value); #define BOOST_TYPEOF_TEXT "Lvalue test..." #include 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)); //msvc BOOST_STATIC_ASSERT((boost::is_same::value)); } #define BOOST_TYPEOF_TEXT "Noncopyable..." #include 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 } }; #define BOOST_TYPEOF_TEXT "STL containers..." #include 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); #define BOOST_TYPEOF_TEXT "function objects..." #include 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); #define BOOST_TYPEOF_TEXT "valarray..." #include BOOST_STATIC_ASSERT(typeof_test >::value); #define BOOST_TYPEOF_TEXT "compiling integral param wrapper..." #include 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(test_integral::foo, (BOOST_TYPEOF_INTEGRAL(test_integral::E)) ) BOOST_TYPEOF_REGISTER_TEMPLATE(test_integral::blah, (BOOST_TYPEOF_INTEGRAL(unsigned long int)) ) BOOST_TYPEOF_REGISTER_TEMPLATE(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 = y; yy = yy; yyy = yyy; } } #define BOOST_TYPEOF_TEXT "ODR..." #include void odr_test() { void odr_test1(); void odr_test2(); odr_test1(); odr_test2(); } #define BOOST_TYPEOF_TEXT "main()..." #include int main() { odr_test(); return 0; } #define BOOST_TYPEOF_TEXT "done!" #include