2003-07-02 21:34:25 +00:00
|
|
|
|
//
|
|
|
|
|
// Copyright 2003 <20> The Trustees of Indiana University. All rights
|
|
|
|
|
// reserved.
|
|
|
|
|
//
|
|
|
|
|
// See the file enable_if_LICENSE for licensing conditions.
|
|
|
|
|
//
|
|
|
|
|
// Authors: Jaakko J<>rvi (jajarvi@osl.iu.edu)
|
|
|
|
|
// Jeremiah Willcock (jewillco@osl.iu.edu)
|
|
|
|
|
// Andrew Lumsdaine (lums@osl.iu.edu)
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include <boost/test/minimal.hpp>
|
2003-09-05 18:22:13 +00:00
|
|
|
|
#include <boost/mpl/not.hpp>
|
2003-07-02 21:34:25 +00:00
|
|
|
|
|
|
|
|
|
#include <boost/utility/enable_if.hpp>
|
|
|
|
|
#include <boost/type_traits/is_arithmetic.hpp>
|
|
|
|
|
|
|
|
|
|
using boost::enable_if;
|
2003-09-05 18:22:13 +00:00
|
|
|
|
using boost::mpl::not_;
|
2003-07-02 21:34:25 +00:00
|
|
|
|
using boost::is_arithmetic;
|
|
|
|
|
|
|
|
|
|
namespace A {
|
|
|
|
|
template<class T>
|
2003-09-05 18:22:13 +00:00
|
|
|
|
typename enable_if<is_arithmetic<T>, bool>::type
|
2003-07-02 21:34:25 +00:00
|
|
|
|
arithmetic_object(T t) { return true; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace B {
|
|
|
|
|
template<class T>
|
2003-09-05 18:22:13 +00:00
|
|
|
|
typename enable_if<not_<is_arithmetic<T> >, bool>::type
|
2003-07-02 21:34:25 +00:00
|
|
|
|
arithmetic_object(T t) { return false; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int test_main(int, char*[])
|
|
|
|
|
{
|
|
|
|
|
using namespace A;
|
|
|
|
|
using namespace B;
|
|
|
|
|
BOOST_TEST(arithmetic_object(1));
|
|
|
|
|
BOOST_TEST(arithmetic_object(1.0));
|
|
|
|
|
|
|
|
|
|
BOOST_TEST(!arithmetic_object("1"));
|
|
|
|
|
BOOST_TEST(!arithmetic_object(static_cast<void*>(0)));
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|