eif_dummy_arg_disambiguation.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Boost enable_if library
  2. // Copyright 2003 (c) The Trustees of Indiana University.
  3. // Use, modification, and distribution is subject to the Boost Software
  4. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. // Authors: Jaakko Jarvi (jajarvi at osl.iu.edu)
  7. // Jeremiah Willcock (jewillco at osl.iu.edu)
  8. // Andrew Lumsdaine (lums at osl.iu.edu)
  9. #include <boost/utility/enable_if.hpp>
  10. #include <boost/type_traits/is_arithmetic.hpp>
  11. #include <boost/detail/lightweight_test.hpp>
  12. using boost::enable_if;
  13. using boost::disable_if;
  14. using boost::is_arithmetic;
  15. template <int N> struct dummy {
  16. dummy(int) {};
  17. };
  18. template<class T>
  19. typename enable_if<is_arithmetic<T>, bool>::type
  20. arithmetic_object(T t, dummy<0> = 0) { return true; }
  21. template<class T>
  22. typename disable_if<is_arithmetic<T>, bool>::type
  23. arithmetic_object(T t, dummy<1> = 0) { return false; }
  24. int main()
  25. {
  26. BOOST_TEST(arithmetic_object(1));
  27. BOOST_TEST(arithmetic_object(1.0));
  28. BOOST_TEST(!arithmetic_object("1"));
  29. BOOST_TEST(!arithmetic_object(static_cast<void*>(0)));
  30. return boost::report_errors();
  31. }