boost_no_func_tmp_order.ipp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // (C) Copyright John Maddock 2001.
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org/libs/config for most recent version.
  6. // MACRO: BOOST_NO_FUNCTION_TEMPLATE_ORDERING
  7. // TITLE: no function template ordering
  8. // DESCRIPTION: The compiler does not perform
  9. // function template ordering or its function
  10. // template ordering is incorrect.
  11. //
  12. // template<typename T> void f(T); // #1
  13. // template<typename T, typename U> void f(T (*)(U)); // #2
  14. // void bar(int);
  15. // f(&bar); // should choose #2.
  16. namespace boost_no_function_template_ordering{
  17. template<typename T>
  18. bool f(T)
  19. {
  20. return false;
  21. }
  22. template<typename T, typename U>
  23. bool f(T (*)(U))
  24. {
  25. return true;
  26. }
  27. void bar(int)
  28. {
  29. }
  30. int test()
  31. {
  32. int i = 0;
  33. return f(i) || !f(&bar);
  34. }
  35. }