function_ptr_from_tpl.cpp 682 B

12345678910111213141516171819202122232425262728
  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 <boost/typeof/typeof.hpp>
  5. #include <boost/type_traits/is_same.hpp>
  6. #include <boost/static_assert.hpp>
  7. void f1() {}
  8. void f2(...) {}
  9. template<class T>
  10. struct tpl1
  11. {
  12. typedef BOOST_TYPEOF_TPL(&f1) type;
  13. };
  14. template<class T>
  15. struct tpl2
  16. {
  17. typedef BOOST_TYPEOF_TPL(&f2) type;
  18. };
  19. typedef void(*fun1_type)();
  20. typedef void(*fun2_type)(...);
  21. BOOST_STATIC_ASSERT((boost::is_same<tpl1<void>::type, fun1_type>::value));
  22. BOOST_STATIC_ASSERT((boost::is_same<tpl2<void>::type, fun2_type>::value));