// (C) Copyright John Maddock 2005. // Use, modification and distribution are subject to 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) #ifdef TEST_STD_HEADERS #include #else #include #endif #include #include #include "verify_return.hpp" struct test_functor { int operator()()const; long operator()(int)const; double operator()(int, char)const; }; void nothing(){} template void test_function(Func*) { typedef typename Func::result_type result_type; test_functor t; Func f1; Func f2(0); Func f3(f1); Func f4(t); f2 = f1; f2 = 0; f2 = t; f2 = std::tr1::ref(t); f2 = std::tr1::cref(t); const Func& cf = f1; std::tr1::swap(f1, f2); if(cf) nothing(); if(cf && f2) nothing(); if(cf || f2) nothing(); if(f2 && !cf) nothing(); //const std::type_info& info = cf.target_type(); test_functor* func1 = f1.template target(); const test_functor* func2 = cf.template target(); // comparison with null: if(0 == f1) nothing(); if(0 != f1) nothing(); if(f2 == 0) nothing(); if(f2 != 0) nothing(); } int main() { BOOST_STATIC_ASSERT((::boost::is_base_and_derived::value)); std::tr1::bad_function_call fe; test_function(static_cast* >(0)); test_function(static_cast* >(0)); test_function(static_cast* >(0)); std::tr1::function f1; verify_return_type(f1(), int(0)); std::tr1::function f2; verify_return_type(f2(0), long(0)); std::tr1::function f3; verify_return_type(f3(0,0), double(0)); //BOOST_STATIC_ASSERT((::boost::is_base_and_derived, std::tr1::function >::value)); //BOOST_STATIC_ASSERT((::boost::is_base_and_derived, std::tr1::function >::value)); return 0; }