// Boost enable_if library // Copyright 2003 (c) The Trustees of Indiana University. // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) // Testing all variations of lazy_enable_if. #include #include #include using boost::lazy_enable_if; using boost::lazy_disable_if; using boost::lazy_enable_if_c; using boost::lazy_disable_if_c; template struct is_int_or_double { BOOST_STATIC_CONSTANT(bool, value = (boost::is_same::value || boost::is_same::value)); }; template struct some_traits { typedef typename T::does_not_exist type; }; template <> struct some_traits { typedef bool type; }; template <> struct some_traits { typedef bool type; }; template struct make_bool { typedef bool type; }; template <> struct make_bool {}; template <> struct make_bool {}; namespace A { template typename lazy_enable_if, some_traits >::type foo(T t) { return true; } template typename lazy_enable_if_c::value, some_traits >::type foo2(T t) { return true; } } namespace B { template typename lazy_disable_if, make_bool >::type foo(T t) { return false; } template typename lazy_disable_if_c::value, make_bool >::type foo2(T t) { return false; } } int main() { using namespace A; using namespace B; BOOST_TEST(foo(1)); BOOST_TEST(foo(1.0)); BOOST_TEST(!foo("1")); BOOST_TEST(!foo(static_cast(0))); BOOST_TEST(foo2(1)); BOOST_TEST(foo2(1.0)); BOOST_TEST(!foo2("1")); BOOST_TEST(!foo2(static_cast(0))); return boost::report_errors(); }