• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/define_struct.hpp>
6 #include <boost/hana/equal.hpp>
7 #include <boost/hana/members.hpp>
8 #include <boost/hana/not_equal.hpp>
9 namespace hana = boost::hana;
10 
11 
12 struct SomeStruct {
13     BOOST_HANA_DEFINE_STRUCT(SomeStruct, (int, x));
14 
operator ==SomeStruct15     constexpr bool operator==(SomeStruct const& other) {
16         return hana::equal(hana::members(*this), hana::members(other));
17     }
18 
operator !=SomeStruct19     constexpr bool operator!=(SomeStruct const& other) {
20         return hana::not_equal(hana::members(*this), hana::members(other));
21     }
22 };
23 
main()24 int main() {
25     static_assert(SomeStruct{5} == SomeStruct{5}, "");
26     static_assert(hana::equal(SomeStruct{5}, SomeStruct{5}), "");
27 }
28