/* @copyright Louis Dionne 2014 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #include #include #include using namespace boost::hana; ////////////////////////////////////////////////////////////////////////////// // 1. `equal_impl` is not provided when the objects share a common type but // that common type isn't Comparable ////////////////////////////////////////////////////////////////////////////// namespace tc1 { struct T { }; struct U { }; struct C { }; } namespace boost { namespace hana { template <> struct common { using type = tc1::C; }; template <> struct convert { static constexpr tc1::C apply(tc1::T) { return {}; } }; template <> struct convert { static constexpr tc1::C apply(tc1::U) { return {}; } }; template <> struct equal_impl { static constexpr bool apply(tc1::T, tc1::T) { return true; } }; template <> struct equal_impl { static constexpr bool apply(tc1::U, tc1::U) { return true; } }; }} BOOST_HANA_CONSTANT_CHECK(not_(is_implemented>)); ////////////////////////////////////////////////////////////////////////////// // 2. Two objects of unrelated data types are unequal by default. ////////////////////////////////////////////////////////////////////////////// namespace tc2 { struct T { }; struct U { }; BOOST_HANA_CONSTANT_CHECK(is_implemented>); BOOST_HANA_CONSTANT_CHECK(not_(equal(T{}, U{}))); } ////////////////////////////////////////////////////////////////////////////// // 3. Two objects of the same data type are not comparable by default. ////////////////////////////////////////////////////////////////////////////// namespace tc3 { struct T { }; BOOST_HANA_CONSTANT_CHECK(not_(is_implemented>)); } ////////////////////////////////////////////////////////////////////////////// // 4. Comparable objects sharing a Comparable common type can be compared. ////////////////////////////////////////////////////////////////////////////// namespace tc4 { struct T { }; struct U { }; struct C { }; } namespace boost { namespace hana { template <> struct common { using type = tc4::C; }; template <> struct convert { static constexpr tc4::C apply(tc4::T) { return {}; } }; template <> struct convert { static constexpr tc4::C apply(tc4::U) { return {}; } }; template <> struct equal_impl { static constexpr bool apply(tc4::C, tc4::C) { return true; } }; template <> struct equal_impl { static constexpr bool apply(tc4::T, tc4::T) { return true; } }; template <> struct equal_impl { static constexpr bool apply(tc4::U, tc4::U) { return true; } }; }} BOOST_HANA_CONSTANT_CHECK(is_implemented>); int main() { }