1 // Copyright Jason Rice 2020 2 // Distributed under the Boost Software License, Version 1.0. 3 // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) 4 5 #include <boost/hana/equal.hpp> 6 #include <boost/hana/not_equal.hpp> 7 #include <boost/hana/tuple.hpp> 8 #include <cassert> 9 namespace hana = boost::hana; 10 11 namespace { 12 template <typename T> 13 struct optional { 14 T t; 15 }; 16 17 template <typename T> operator ==(optional<T> const & o,T const & t)18 constexpr bool operator==(optional<T> const& o, T const& t) { 19 return o.t == t; 20 } 21 template <typename T> operator ==(T const & t,optional<T> const & o)22 constexpr bool operator==(T const& t, optional<T> const& o) { 23 return o.t == t; 24 } 25 template <typename T> operator !=(optional<T> const & o,T const & t)26 constexpr bool operator!=(optional<T> const& o, T const& t) { 27 return o.t != t; 28 } 29 template <typename T> operator !=(T const & t,optional<T> const & o)30 constexpr bool operator!=(T const& t, optional<T> const& o) { 31 return o.t != t; 32 } 33 } 34 main()35int main() { 36 boost::hana::tuple<int> x{}; 37 optional<boost::hana::tuple<int>> attr{x}; 38 assert(attr == x); // <-- Kablooey! 39 } 40