lsa: define NameLsa operator==

refs #4094

Change-Id: I99650cb3c6c452b157595a394c30227e47aa88c8
diff --git a/src/lsa/name-lsa.cpp b/src/lsa/name-lsa.cpp
index 50e4cb7..ce743a3 100644
--- a/src/lsa/name-lsa.cpp
+++ b/src/lsa/name-lsa.cpp
@@ -112,12 +112,6 @@
   m_npl = npl;
 }
 
-bool
-NameLsa::isEqualContent(const NameLsa& other) const
-{
-  return m_npl == other.getNpl();
-}
-
 std::string
 NameLsa::toString() const
 {
diff --git a/src/lsa/name-lsa.hpp b/src/lsa/name-lsa.hpp
index cb85ac2..7c82b90 100644
--- a/src/lsa/name-lsa.hpp
+++ b/src/lsa/name-lsa.hpp
@@ -25,6 +25,8 @@
 #include "lsa.hpp"
 #include "name-prefix-list.hpp"
 
+#include <boost/operators.hpp>
+
 namespace nlsr {
 
 /*!
@@ -33,7 +35,7 @@
                 Lsa
                 Name+
  */
-class NameLsa : public Lsa
+class NameLsa : public Lsa, private boost::equality_comparable<NameLsa>
 {
 public:
   NameLsa() = default;
@@ -82,9 +84,6 @@
     m_npl.erase(name);
   }
 
-  bool
-  isEqualContent(const NameLsa& other) const;
-
   template<ndn::encoding::Tag TAG>
   size_t
   wireEncode(ndn::EncodingImpl<TAG>& block) const;
@@ -101,6 +100,17 @@
   std::tuple<bool, std::list<ndn::Name>, std::list<ndn::Name>>
   update(const std::shared_ptr<Lsa>& lsa) override;
 
+private: // non-member operators
+  // NOTE: the following "hidden friend" operators are available via
+  //       argument-dependent lookup only and must be defined inline.
+  // boost::equality_comparable provides != operator.
+
+  friend bool
+  operator==(const NameLsa& lhs, const NameLsa& rhs)
+  {
+    return lhs.m_npl == rhs.m_npl;
+  }
+
 private:
   NamePrefixList m_npl;
 };
diff --git a/tests/lsa/test-name-lsa.cpp b/tests/lsa/test-name-lsa.cpp
index 3438931..a4578a0 100644
--- a/tests/lsa/test-name-lsa.cpp
+++ b/tests/lsa/test-name-lsa.cpp
@@ -107,21 +107,22 @@
 
 BOOST_AUTO_TEST_CASE(OperatorEquals)
 {
-  NameLsa lsa1;
-  NameLsa lsa2;
   ndn::Name name1("/ndn/test/name1");
   ndn::Name name2("/ndn/test/name2");
   ndn::Name name3("/ndn/some/other/name1");
 
+  NameLsa lsa1;
   lsa1.addName(name1);
   lsa1.addName(name2);
   lsa1.addName(name3);
 
+  NameLsa lsa2;
   lsa2.addName(name1);
   lsa2.addName(name2);
-  lsa2.addName(name3);
+  BOOST_CHECK_NE(lsa1, lsa2);
 
-  BOOST_CHECK(lsa1.isEqualContent(lsa2));
+  lsa2.addName(name3);
+  BOOST_CHECK_EQUAL(lsa1, lsa2);
 }
 
 BOOST_AUTO_TEST_CASE(Update)