Files
utility/test/enable_if_dummy_arg_disambiguation.cpp

45 lines
1.0 KiB
C++
Raw Normal View History

2003-07-02 21:34:25 +00:00
//
// Copyright 2003 <20> The Trustees of Indiana University.
2003-07-02 21:34:25 +00:00
//
// See the file enable_if_LICENSE for licensing conditions.
//
2003-10-06 21:53:54 +00:00
// Authors: Jaakko J<>rvi (jajarvi at osl.iu.edu)
// Jeremiah Willcock (jewillco at osl.iu.edu)
// Andrew Lumsdaine (lums at osl.iu.edu)
2003-07-02 21:34:25 +00:00
//
#include <boost/test/minimal.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_arithmetic.hpp>
using boost::enable_if;
2003-09-05 18:24:24 +00:00
using boost::disable_if;
2003-07-02 21:34:25 +00:00
using boost::is_arithmetic;
template <int N> struct dummy {
dummy(int) {};
};
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, dummy<0> = 0) { return true; }
template<class T>
2003-09-05 18:24:24 +00:00
typename disable_if<is_arithmetic<T>, bool>::type
2003-07-02 21:34:25 +00:00
arithmetic_object(T t, dummy<1> = 0) { return false; }
int test_main(int, char*[])
{
2003-11-03 19:02:40 +00:00
BOOST_CHECK(arithmetic_object(1));
BOOST_CHECK(arithmetic_object(1.0));
2003-07-02 21:34:25 +00:00
2003-11-03 19:02:40 +00:00
BOOST_CHECK(!arithmetic_object("1"));
BOOST_CHECK(!arithmetic_object(static_cast<void*>(0)));
2003-07-02 21:34:25 +00:00
return 0;
}