eif_no_disambiguation.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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/config.hpp>
  10. #include <boost/utility/enable_if.hpp>
  11. #include <boost/type_traits/is_arithmetic.hpp>
  12. #include <boost/detail/lightweight_test.hpp>
  13. using boost::enable_if;
  14. using boost::is_arithmetic;
  15. template<class T> struct not_
  16. {
  17. BOOST_STATIC_CONSTANT( bool, value = !T::value );
  18. };
  19. template<class T>
  20. typename enable_if<is_arithmetic<T>, bool>::type
  21. arithmetic_object(T t) { return true; }
  22. template<class T>
  23. typename enable_if<not_<is_arithmetic<T> >, bool>::type
  24. arithmetic_object(T t) { return false; }
  25. int main()
  26. {
  27. BOOST_TEST(arithmetic_object(1));
  28. BOOST_TEST(arithmetic_object(1.0));
  29. BOOST_TEST(!arithmetic_object("1"));
  30. BOOST_TEST(!arithmetic_object(static_cast<void*>(0)));
  31. return boost::report_errors();
  32. }