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