forked from boostorg/utility
Tests for enable_if
[SVN r1401]
This commit is contained in:
1 parent
46f8fa5e6f
commit
037808a780
8 files changed
+386
No files matched your search
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// Copyright 2003 © 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>
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_arithmetic.hpp>
|
||||
|
||||
using boost::enable_if;
|
||||
using boost::disable_if;
|
||||
using boost::is_arithmetic;
|
||||
|
||||
struct container {
|
||||
template <class T>
|
||||
typename enable_if<is_arithmetic<T>::value, bool>::type
|
||||
arithmetic_object(const T&, const int* /* disambiguate */ = 0) {return true;}
|
||||
|
||||
template <class T>
|
||||
typename disable_if<is_arithmetic<T>::value, bool>::type
|
||||
arithmetic_object(const T&) {return false;}
|
||||
};
|
||||
|
||||
int test_main(int, char*[])
|
||||
{
|
||||
|
||||
BOOST_TEST(container().arithmetic_object(1));
|
||||
BOOST_TEST(container().arithmetic_object(1.0));
|
||||
|
||||
BOOST_TEST(!container().arithmetic_object("1"));
|
||||
BOOST_TEST(!container().arithmetic_object(static_cast<void*>(0)));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user