/* Copyright 2018 Glen Joseph Fernandes (glenjofe@gmail.com) Distributed under 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) */ #include #include "test.hpp" template struct Constant { enum { value = B }; }; template struct Check : Constant { }; template<> struct Check : Constant { }; class Construct { public: template Construct(T, typename boost::enable_if_::value>::type* = 0) : value_(true) { } template Construct(T, typename boost::enable_if_::value>::type* = 0) : value_(false) { } bool value() const { return value_; } private: bool value_; }; template struct Specialize; template struct Specialize::value>::type> : Constant { }; template struct Specialize::value>::type> : Constant { }; template typename boost::enable_if_::value, bool>::type Returns(T) { return true; } template typename boost::enable_if_::value, bool>::type Returns(T) { return false; } #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) template boost::enable_if_t::value, bool> Alias(T) { return true; } template boost::enable_if_t::value, bool> Alias(T) { return false; } #endif TT_TEST_BEGIN(enable_if) BOOST_CHECK(!Construct(1).value()); BOOST_CHECK(Construct(1L).value()); BOOST_CHECK(!Specialize::value); BOOST_CHECK(Specialize::value); BOOST_CHECK(!Returns(1)); BOOST_CHECK(Returns(1L)); #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) BOOST_CHECK(!Alias(1)); BOOST_CHECK(Alias(1L)); #endif TT_TEST_END