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/config.hpp>
14#include <boost/utility/enable_if.hpp>
15#include <boost/type_traits/is_arithmetic.hpp>
16#include <boost/core/lightweight_test.hpp>
17
18using boost::enable_if;
19using boost::is_arithmetic;
20
21template<class T> struct not_
22{
23 BOOST_STATIC_CONSTANT( bool, value = !T::value );
24};
25
26namespace A {
27 template<class T>
28 typename enable_if<is_arithmetic<T>, bool>::type
29 arithmetic_object(T /*t*/) { return true; }
30}
31
32namespace B {
33 template<class T>
34 typename enable_if<not_<is_arithmetic<T> >, bool>::type
35 arithmetic_object(T /*t*/) { return false; }
36}
37
38int main()
39{
40 using namespace A;
41 using namespace B;
42 BOOST_TEST(arithmetic_object(1));
43 BOOST_TEST(arithmetic_object(1.0));
44
45 BOOST_TEST(!arithmetic_object("1"));
46 BOOST_TEST(!arithmetic_object(static_cast<void*>(0)));
47
48 return boost::report_errors();
49}
50

source code of boost/libs/core/test/eif_namespace_disambiguation.cpp