Skip to content

Commit

Permalink
Add an implementation of or_ using is_same.
Browse files Browse the repository at this point in the history
  • Loading branch information
ldionne committed May 2, 2014
1 parent 76d87a4 commit 0b4fcbe
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
39 changes: 39 additions & 0 deletions include/boost/mpl11/detail/logical_or/strict_is_same.hpp
Original file line number Diff line number Diff line change
@@ -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 <boost/mpl11/bool.hpp>
#include <boost/mpl11/detail/std_is_same.hpp>


namespace boost { namespace mpl11 { namespace detail { namespace logical_or {
template <bool ...>
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 <typename ...xs>
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
2 changes: 2 additions & 0 deletions test/detail/logical_or.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

#include <boost/mpl11/detail/logical_or/lazy_naive_struct.hpp>
#include <boost/mpl11/detail/logical_or/strict_is_same.hpp>
#include <boost/mpl11/detail/logical_or/strict_noexcept.hpp>
#include <boost/mpl11/detail/logical_or/strict_overload.hpp>
#include <boost/mpl11/detail/logical_or/strict_specialization.hpp>
Expand All @@ -23,6 +24,7 @@ struct tests
: detail::test_logical_or_strict<detail::logical_or::strict_overload>
, detail::test_logical_or_strict<detail::logical_or::strict_noexcept>
, detail::test_logical_or_strict<detail::logical_or::strict_specialization>
, detail::test_logical_or_strict<detail::logical_or::strict_is_same>

, detail::test_logical_or_lazy<detail::logical_or::lazy_naive_struct>
{ };
Expand Down

0 comments on commit 0b4fcbe

Please sign in to comment.