From 0b4fcbe928ab428460077b53bff53a71af756872 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Fri, 2 May 2014 15:44:27 -0400 Subject: [PATCH] Add an implementation of or_ using is_same. --- .../detail/logical_or/strict_is_same.hpp | 39 +++++++++++++++++++ test/detail/logical_or.cpp | 2 + 2 files changed, 41 insertions(+) create mode 100644 include/boost/mpl11/detail/logical_or/strict_is_same.hpp diff --git a/include/boost/mpl11/detail/logical_or/strict_is_same.hpp b/include/boost/mpl11/detail/logical_or/strict_is_same.hpp new file mode 100644 index 00000000..c412f4a7 --- /dev/null +++ b/include/boost/mpl11/detail/logical_or/strict_is_same.hpp @@ -0,0 +1,39 @@ +/*! + * @file + * Defines `boost::mpl11::detail::logical_or::strict_is_same`. + * + * + * @copyright Louis Dionne 2014 + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE.md or copy at + * http://www.boost.org/LICENSE_1_0.txt) + */ + +#ifndef BOOST_MPL11_DETAIL_LOGICAL_OR_STRICT_IS_SAME_HPP +#define BOOST_MPL11_DETAIL_LOGICAL_OR_STRICT_IS_SAME_HPP + +#include +#include + + +namespace boost { namespace mpl11 { namespace detail { namespace logical_or { + template + struct strict_is_same_impl; + + /*! + * @ingroup details + * + * Strict (non short-circuiting) logical or implemented with `is_same`. + * + * All credit goes to Roland Bock for the technique. + */ + template + using strict_is_same = bool_< + !std_is_same< + strict_is_same_impl<(bool)xs::type::value...>, + strict_is_same_impl<(xs::type::value, false)...> + >::value + >; +}}}} // end namespace boost::mpl11::detail::logical_or + +#endif // !BOOST_MPL11_DETAIL_LOGICAL_OR_STRICT_IS_SAME_HPP diff --git a/test/detail/logical_or.cpp b/test/detail/logical_or.cpp index a1a85695..3068b55f 100644 --- a/test/detail/logical_or.cpp +++ b/test/detail/logical_or.cpp @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -23,6 +24,7 @@ struct tests : detail::test_logical_or_strict , detail::test_logical_or_strict , detail::test_logical_or_strict + , detail::test_logical_or_strict , detail::test_logical_or_lazy { };