1 // Boost enable_if library
3 // Copyright 2003 (c) The Trustees of Indiana University.
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)
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)
13 #include <boost/test/minimal.hpp>
15 #include <boost/utility/enable_if.hpp>
16 #include <boost/type_traits/is_arithmetic.hpp>
18 using boost::enable_if;
19 using boost::disable_if;
20 using boost::is_arithmetic;
22 template <int N> struct dummy {
27 typename enable_if<is_arithmetic<T>, bool>::type
28 arithmetic_object(T t, dummy<0> = 0) { return true; }
31 typename disable_if<is_arithmetic<T>, bool>::type
32 arithmetic_object(T t, dummy<1> = 0) { return false; }
35 int test_main(int, char*[])
38 BOOST_CHECK(arithmetic_object(1));
39 BOOST_CHECK(arithmetic_object(1.0));
41 BOOST_CHECK(!arithmetic_object("1"));
42 BOOST_CHECK(!arithmetic_object(static_cast<void*>(0)));