Imported Upstream version 1.51.0
[platform/upstream/boost.git] / libs / utility / enable_if / test / namespace_disambiguation.cpp
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/test/minimal.hpp>
14 #include <boost/mpl/not.hpp>
15
16 #include <boost/utility/enable_if.hpp>
17 #include <boost/type_traits/is_arithmetic.hpp>
18
19 using boost::enable_if;
20 using boost::mpl::not_;
21 using boost::is_arithmetic;
22
23 namespace A {
24   template<class T>
25   typename enable_if<is_arithmetic<T>, bool>::type
26   arithmetic_object(T t) { return true; }
27 }
28
29 namespace B {
30   template<class T>
31   typename enable_if<not_<is_arithmetic<T> >, bool>::type
32   arithmetic_object(T t) { return false; }
33 }
34
35 int test_main(int, char*[])
36 {
37   using namespace A;
38   using namespace B;
39   BOOST_CHECK(arithmetic_object(1));
40   BOOST_CHECK(arithmetic_object(1.0));
41
42   BOOST_CHECK(!arithmetic_object("1"));  
43   BOOST_CHECK(!arithmetic_object(static_cast<void*>(0)));  
44
45   return 0;
46 }
47