function_ptr.cpp 1.1 KB

1234567891011121314151617181920212223242526
  1. // Copyright (C) 2006 Arkadiy Vertleyb
  2. // Use, modification and distribution is subject to the Boost Software
  3. // License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
  4. #include "test.hpp"
  5. BOOST_STATIC_ASSERT(boost::type_of::test<double(*)()>::value);
  6. BOOST_STATIC_ASSERT(boost::type_of::test<double(*)(int, double, short, char*, bool, char, float, long, unsigned short)>::value);
  7. BOOST_STATIC_ASSERT(boost::type_of::test<void(*)()>::value);
  8. BOOST_STATIC_ASSERT(boost::type_of::test<void(*)(int, double, short, char*, bool, char, float, long, unsigned short)>::value);
  9. BOOST_STATIC_ASSERT(boost::type_of::test<void(*)(...)>::value);
  10. BOOST_STATIC_ASSERT(boost::type_of::test<void(*)(int, double, short, char*, bool, char, float, long, unsigned short, ...)>::value);
  11. // check that const gets stripped from function pointer
  12. int foo1(double);
  13. int foo2(...);
  14. typedef int(*PTR1)(double);
  15. typedef int(*PTR2)(...);
  16. typedef const PTR1 CPTR1;
  17. typedef const PTR2 CPTR2;
  18. CPTR1 cptr1 = foo1;
  19. CPTR2 cptr2 = foo2;
  20. BOOST_STATIC_ASSERT((boost::is_same<BOOST_TYPEOF(cptr1), PTR1>::value));
  21. BOOST_STATIC_ASSERT((boost::is_same<BOOST_TYPEOF(cptr2), PTR2>::value));