diff --git a/ndn-cxx/encoding/block.hpp b/ndn-cxx/encoding/block.hpp index 0aa4f7f6..e0d21b8b 100644 --- a/ndn-cxx/encoding/block.hpp +++ b/ndn-cxx/encoding/block.hpp @@ -29,6 +29,8 @@ #include "ndn-cxx/encoding/tlv.hpp" #include "ndn-cxx/util/span.hpp" +#include + namespace boost::asio { class const_buffer; } // namespace boost::asio @@ -39,7 +41,7 @@ namespace ndn { * @brief Represents a TLV element of the NDN packet format. * @sa https://docs.named-data.net/NDN-packet-spec/0.3/tlv.html */ -class Block +class Block : private boost::equality_comparable { public: using value_type = Buffer::value_type; @@ -463,13 +465,6 @@ public: // misc */ operator boost::asio::const_buffer() const; -protected: - /** - * @brief Returns whether this Block has the same TLV-TYPE/TLV-LENGTH/TLV-VALUE as @p other. - */ - bool - equals(const Block& other) const noexcept; - private: /** * @brief Estimate Block size as if sub-elements are encoded into TLV-VALUE. @@ -491,12 +486,19 @@ private: size_t encode(EncodingBuffer& encoder); + /** + * @brief Returns whether this Block has the same TLV-TYPE/TLV-LENGTH/TLV-VALUE as @p other. + */ + bool + equals(const Block& other) const noexcept; + void print(std::ostream& os) const; 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. /** * @brief Compare whether two Blocks have the same TLV-TYPE, TLV-LENGTH, and TLV-VALUE. @@ -507,12 +509,6 @@ private: // non-member operators return lhs.equals(rhs); } - friend bool - operator!=(const Block& lhs, const Block& rhs) noexcept - { - return !lhs.equals(rhs); - } - /** * @brief Print @p block to @p os. * diff --git a/ndn-cxx/encoding/encoder.hpp b/ndn-cxx/encoding/encoder.hpp index 1d453142..3df1f482 100644 --- a/ndn-cxx/encoding/encoder.hpp +++ b/ndn-cxx/encoding/encoder.hpp @@ -252,7 +252,7 @@ size_t Encoder::prependRange(Iterator first, Iterator last) { using ValueType = typename std::iterator_traits::value_type; - static_assert(sizeof(ValueType) == 1 && !std::is_same_v, ""); + static_assert(sizeof(ValueType) == 1 && !std::is_same_v); size_t length = std::distance(first, last); reserveFront(length); @@ -267,7 +267,7 @@ size_t Encoder::appendRange(Iterator first, Iterator last) { using ValueType = typename std::iterator_traits::value_type; - static_assert(sizeof(ValueType) == 1 && !std::is_same_v, ""); + static_assert(sizeof(ValueType) == 1 && !std::is_same_v); size_t length = std::distance(first, last); reserveBack(length); diff --git a/ndn-cxx/encoding/nfd-constants.cpp b/ndn-cxx/encoding/nfd-constants.cpp index c6f5a586..ede579e1 100644 --- a/ndn-cxx/encoding/nfd-constants.cpp +++ b/ndn-cxx/encoding/nfd-constants.cpp @@ -121,8 +121,8 @@ operator>>(std::istream& is, RouteOrigin& routeOrigin) routeOrigin = ROUTE_ORIGIN_STATIC; else { // To reject negative numbers, we parse as a wider signed type, and compare with the range. - static_assert(std::numeric_limits>::max() <= - std::numeric_limits::max(), ""); + using RouteOriginUnderlyingType = std::underlying_type_t; + static_assert(std::numeric_limits::max() <= std::numeric_limits::max()); int v = -1; try { @@ -131,8 +131,8 @@ operator>>(std::istream& is, RouteOrigin& routeOrigin) catch (const boost::bad_lexical_cast&) { } - if (v >= std::numeric_limits>::min() && - v <= std::numeric_limits>::max()) { + if (v >= std::numeric_limits::min() && + v <= std::numeric_limits::max()) { routeOrigin = static_cast(v); } else { diff --git a/ndn-cxx/impl/common-pch.hpp b/ndn-cxx/impl/common-pch.hpp index c7fcd43e..adc09cdf 100644 --- a/ndn-cxx/impl/common-pch.hpp +++ b/ndn-cxx/impl/common-pch.hpp @@ -55,6 +55,7 @@ #include #include #include +#include #include #endif // NDN_CXX_IMPL_COMMON_PCH_HPP diff --git a/ndn-cxx/ims/in-memory-storage.cpp b/ndn-cxx/ims/in-memory-storage.cpp index 71156856..36ccb08d 100644 --- a/ndn-cxx/ims/in-memory-storage.cpp +++ b/ndn-cxx/ims/in-memory-storage.cpp @@ -27,14 +27,6 @@ namespace ndn { constexpr size_t MIN_CAPACITY = 16; constexpr time::milliseconds ZERO_WINDOW = 0_ms; -InMemoryStorage::const_iterator::const_iterator(const Data* ptr, const Cache* cache, - Cache::index::type::iterator it) - : m_ptr(ptr) - , m_cache(cache) - , m_it(it) -{ -} - InMemoryStorage::const_iterator& InMemoryStorage::const_iterator::operator++() { @@ -45,42 +37,9 @@ InMemoryStorage::const_iterator::operator++() else { m_ptr = nullptr; } - return *this; } -InMemoryStorage::const_iterator -InMemoryStorage::const_iterator::operator++(int) -{ - InMemoryStorage::const_iterator i(*this); - this->operator++(); - return i; -} - -InMemoryStorage::const_iterator::reference -InMemoryStorage::const_iterator::operator*() -{ - return *m_ptr; -} - -InMemoryStorage::const_iterator::pointer -InMemoryStorage::const_iterator::operator->() -{ - return m_ptr; -} - -bool -InMemoryStorage::const_iterator::operator==(const const_iterator& rhs) -{ - return m_it == rhs.m_it; -} - -bool -InMemoryStorage::const_iterator::operator!=(const const_iterator& rhs) -{ - return m_it != rhs.m_it; -} - InMemoryStorage::InMemoryStorage(size_t limit) : m_limit(limit) , m_nPackets(0) diff --git a/ndn-cxx/ims/in-memory-storage.hpp b/ndn-cxx/ims/in-memory-storage.hpp index 22cd3b53..30965421 100644 --- a/ndn-cxx/ims/in-memory-storage.hpp +++ b/ndn-cxx/ims/in-memory-storage.hpp @@ -24,7 +24,6 @@ #include "ndn-cxx/ims/in-memory-storage-entry.hpp" -#include #include #include @@ -58,39 +57,35 @@ public: > >; - /** @brief Represents a self-defined const_iterator for the in-memory storage. - * - * @note Don't try to instantiate this class directly, use InMemoryStorage::begin() instead. + /** + * @brief Represents a const_iterator for the in-memory storage. + * @note Do not instantiate this class directly, use InMemoryStorage::begin() instead. */ - class const_iterator + class const_iterator : public boost::forward_iterator_helper { public: - using iterator_category = std::input_iterator_tag; - using value_type = const Data; - using difference_type = std::ptrdiff_t; - using pointer = value_type*; - using reference = value_type&; - const_iterator(const Data* ptr, const Cache* cache, - Cache::index::type::iterator it); + Cache::index::type::iterator it) noexcept + : m_ptr(ptr) + , m_cache(cache) + , m_it(it) + { + } + + reference + operator*() const noexcept + { + return *m_ptr; + } const_iterator& operator++(); - const_iterator - operator++(int); - - reference - operator*(); - - pointer - operator->(); - - bool - operator==(const const_iterator& rhs); - - bool - operator!=(const const_iterator& rhs); + friend bool + operator==(const const_iterator& lhs, const const_iterator& rhs) noexcept + { + return lhs.m_it == rhs.m_it; + } private: const Data* m_ptr; diff --git a/ndn-cxx/interest.hpp b/ndn-cxx/interest.hpp index 5ca79248..7b817ab7 100644 --- a/ndn-cxx/interest.hpp +++ b/ndn-cxx/interest.hpp @@ -55,10 +55,8 @@ public: using tlv::Error::Error; }; - class Nonce final : public std::array + class Nonce final : public std::array, private boost::equality_comparable { - using Base = std::array; - public: Nonce() = default; @@ -80,17 +78,12 @@ public: 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 Nonce& lhs, const Nonce& rhs) noexcept { - return static_cast(lhs) == static_cast(rhs); - } - - friend bool - operator!=(const Nonce& lhs, const Nonce& rhs) noexcept - { - return static_cast(lhs) != static_cast(rhs); + return std::equal(lhs.begin(), lhs.end(), rhs.begin()); } friend std::ostream& diff --git a/ndn-cxx/key-locator.cpp b/ndn-cxx/key-locator.cpp index 03fae6bf..78f55c08 100644 --- a/ndn-cxx/key-locator.cpp +++ b/ndn-cxx/key-locator.cpp @@ -50,12 +50,12 @@ KeyLocator::wireEncode(EncodingImpl& encoder) const size_t totalLength = 0; - auto visitor = boost::hana::overload( + std::visit(boost::hana::overload( [] (std::monostate) {}, // nothing to encode, TLV-VALUE is empty [&] (const Name& name) { totalLength += name.wireEncode(encoder); }, [&] (const Block& digest) { totalLength += prependBlock(encoder, digest); }, - [] (uint32_t type) { NDN_THROW(Error("Unsupported KeyLocator type " + to_string(type))); }); - visit(visitor, m_locator); + [] (uint32_t type) { NDN_THROW(Error("Unsupported KeyLocator type " + to_string(type))); }), + m_locator); totalLength += encoder.prependVarNumber(totalLength); totalLength += encoder.prependVarNumber(tlv::KeyLocator); @@ -183,10 +183,10 @@ KeyLocator::setKeyDigest(const ConstBufferPtr& keyDigest) return *this; } -std::ostream& -operator<<(std::ostream& os, const KeyLocator& keyLocator) +void +KeyLocator::print(std::ostream& os) const { - auto visitor = boost::hana::overload( + std::visit(boost::hana::overload( [&] (std::monostate) { os << "None"; }, @@ -202,9 +202,8 @@ operator<<(std::ostream& os, const KeyLocator& keyLocator) }, [&] (uint32_t type) { os << "Unknown(" << type << ")"; - }); - visit(visitor, keyLocator.m_locator); - return os; + }), + m_locator); } } // namespace ndn diff --git a/ndn-cxx/key-locator.hpp b/ndn-cxx/key-locator.hpp index 4c322617..76037539 100644 --- a/ndn-cxx/key-locator.hpp +++ b/ndn-cxx/key-locator.hpp @@ -28,7 +28,7 @@ namespace ndn { -class KeyLocator +class KeyLocator : private boost::equality_comparable { public: class Error : public tlv::Error @@ -124,9 +124,14 @@ public: // attributes KeyLocator& setKeyDigest(const ConstBufferPtr& keyDigest); +private: + void + print(std::ostream& os) const; + 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 KeyLocator& lhs, const KeyLocator& rhs) @@ -134,10 +139,11 @@ private: // non-member operators return lhs.m_locator == rhs.m_locator; } - friend bool - operator!=(const KeyLocator& lhs, const KeyLocator& rhs) + friend std::ostream& + operator<<(std::ostream& os, const KeyLocator& kl) { - return lhs.m_locator != rhs.m_locator; + kl.print(os); + return os; } private: @@ -148,15 +154,10 @@ private: std::variant m_locator; mutable Block m_wire; - - friend std::ostream& operator<<(std::ostream&, const KeyLocator&); }; NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(KeyLocator); -std::ostream& -operator<<(std::ostream& os, const KeyLocator& keyLocator); - } // namespace ndn #endif // NDN_CXX_KEY_LOCATOR_HPP diff --git a/ndn-cxx/lp/field.hpp b/ndn-cxx/lp/field.hpp index 3d72fdaf..741cb59b 100644 --- a/ndn-cxx/lp/field.hpp +++ b/ndn-cxx/lp/field.hpp @@ -51,10 +51,10 @@ struct Fragment {}; template struct Field { - static_assert(std::is_same_v, ""); - static_assert(std::is_same_v, ""); - static_assert(std::is_default_constructible_v, ""); - static_assert(std::is_copy_constructible_v, ""); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_default_constructible_v); + static_assert(std::is_copy_constructible_v); BOOST_CONCEPT_USAGE(Field) { diff --git a/ndn-cxx/metadata-object.cpp b/ndn-cxx/metadata-object.cpp index 69db1875..03a0b3e5 100644 --- a/ndn-cxx/metadata-object.cpp +++ b/ndn-cxx/metadata-object.cpp @@ -25,9 +25,6 @@ namespace ndn { -static_assert(std::is_convertible_v, - "MetadataObject::Error must inherit from tlv::Error"); - MetadataObject::MetadataObject() = default; MetadataObject::MetadataObject(const Data& data) diff --git a/ndn-cxx/name-component.hpp b/ndn-cxx/name-component.hpp index 5870bb84..7bc90e80 100644 --- a/ndn-cxx/name-component.hpp +++ b/ndn-cxx/name-component.hpp @@ -109,7 +109,7 @@ setConventionDecoding(Convention convention); * or, if it is an `ImplicitSha256DigestComponent` or a `ParametersSha256DigestComponent`, * its TLV-LENGTH is not 32. */ -class Component : public Block +class Component : public Block, private boost::less_than_comparable { public: class Error : public Block::Error @@ -482,23 +482,12 @@ public: // comparison } /** - * @brief Check whether this is the same component as @p other. - * @param other The name component to compare with - * @return true if the components are equal, false otherwise. - */ - bool - equals(const Component& other) const noexcept - { - return Block::equals(other); - } - - /** - * @brief Compare this to the other Component using NDN canonical ordering. + * @brief Compare this component to @p other using NDN canonical ordering. * - * @param other The other Component to compare with. - * @retval negative this comes before other in canonical ordering - * @retval zero this equals other - * @retval positive this comes after other in canonical ordering + * @param other The name component to compare with. + * @retval negative This component comes before @p other in canonical ordering + * @retval zero This component equals @p other + * @retval positive This component comes after @p other in canonical ordering * * @sa https://docs.named-data.net/NDN-packet-spec/0.3/name.html#canonical-order */ @@ -543,18 +532,8 @@ private: private: // non-member operators // NOTE: the following "hidden friend" operators are available via // argument-dependent lookup only and must be defined inline. - - friend bool - operator==(const Component& lhs, const Component& rhs) noexcept - { - return lhs.equals(rhs); - } - - friend bool - operator!=(const Component& lhs, const Component& rhs) noexcept - { - return !lhs.equals(rhs); - } + // Block provides == and != operators. + // boost::less_than_comparable provides <=, >=, and > operators. friend bool operator<(const Component& lhs, const Component& rhs) @@ -562,24 +541,6 @@ private: // non-member operators return lhs.compare(rhs) < 0; } - friend bool - operator<=(const Component& lhs, const Component& rhs) - { - return lhs.compare(rhs) <= 0; - } - - friend bool - operator>(const Component& lhs, const Component& rhs) - { - return lhs.compare(rhs) > 0; - } - - friend bool - operator>=(const Component& lhs, const Component& rhs) - { - return lhs.compare(rhs) >= 0; - } - friend std::ostream& operator<<(std::ostream& os, const Component& component) { @@ -589,7 +550,7 @@ private: // non-member operators // !!! NOTE TO IMPLEMENTOR !!! // - // This class MUST NOT contain any data fields. + // This class MUST NOT contain any non-static data members. // Block can be reinterpret_cast'ed as Component type. }; diff --git a/ndn-cxx/name.hpp b/ndn-cxx/name.hpp index 9968e5c8..ad68c33b 100644 --- a/ndn-cxx/name.hpp +++ b/ndn-cxx/name.hpp @@ -41,7 +41,7 @@ using PartialName = Name; * @brief Represents an absolute name. * @sa https://docs.named-data.net/NDN-packet-spec/0.3/name.html */ -class Name +class Name : private boost::totally_ordered { public: // nested types using Error = name::Component::Error; @@ -646,6 +646,7 @@ public: // algorithms private: // non-member operators // NOTE: the following "hidden friend" operators are available via // argument-dependent lookup only and must be defined inline. + // boost::totally_ordered provides !=, <=, >=, and > operators. friend bool operator==(const Name& lhs, const Name& rhs) noexcept @@ -653,36 +654,12 @@ private: // non-member operators return lhs.equals(rhs); } - friend bool - operator!=(const Name& lhs, const Name& rhs) noexcept - { - return !lhs.equals(rhs); - } - friend bool operator<(const Name& lhs, const Name& rhs) { return lhs.compare(rhs) < 0; } - friend bool - operator<=(const Name& lhs, const Name& rhs) - { - return lhs.compare(rhs) <= 0; - } - - friend bool - operator>(const Name& lhs, const Name& rhs) - { - return lhs.compare(rhs) > 0; - } - - friend bool - operator>=(const Name& lhs, const Name& rhs) - { - return lhs.compare(rhs) >= 0; - } - /** * @brief Print the URI representation of a name. * @sa https://docs.named-data.net/NDN-packet-spec/0.3/name.html#ndn-uri-scheme diff --git a/ndn-cxx/net/face-uri.cpp b/ndn-cxx/net/face-uri.cpp index 0a40b5a9..da5905f0 100644 --- a/ndn-cxx/net/face-uri.cpp +++ b/ndn-cxx/net/face-uri.cpp @@ -181,25 +181,24 @@ std::string FaceUri::toString() const { std::ostringstream os; - os << *this; + print(os); return os.str(); } -std::ostream& -operator<<(std::ostream& os, const FaceUri& uri) +void +FaceUri::print(std::ostream& os) const { - os << uri.m_scheme << "://"; - if (uri.m_isV6) { - os << "[" << uri.m_host << "]"; + os << m_scheme << "://"; + if (m_isV6) { + os << "[" << m_host << "]"; } else { - os << uri.m_host; + os << m_host; } - if (!uri.m_port.empty()) { - os << ":" << uri.m_port; + if (!m_port.empty()) { + os << ":" << m_port; } - os << uri.m_path; - return os; + os << m_path; } diff --git a/ndn-cxx/net/face-uri.hpp b/ndn-cxx/net/face-uri.hpp index aab25976..2adbc380 100644 --- a/ndn-cxx/net/face-uri.hpp +++ b/ndn-cxx/net/face-uri.hpp @@ -178,13 +178,17 @@ public: // canonical FaceUri boost::asio::io_service& io, time::nanoseconds timeout) const; +private: + void + print(std::ostream& os) const; + private: // non-member operators // NOTE: the following "hidden friend" operators are available via // argument-dependent lookup only and must be defined inline. // boost::totally_ordered provides !=, <=, >=, and > operators. friend bool - operator==(const FaceUri& lhs, const FaceUri& rhs) + operator==(const FaceUri& lhs, const FaceUri& rhs) noexcept { return lhs.m_isV6 == rhs.m_isV6 && lhs.m_scheme == rhs.m_scheme && @@ -194,25 +198,27 @@ private: // non-member operators } friend bool - operator<(const FaceUri& lhs, const FaceUri& rhs) + operator<(const FaceUri& lhs, const FaceUri& rhs) noexcept { return std::tie(lhs.m_scheme, lhs.m_isV6, lhs.m_host, lhs.m_port, lhs.m_path) < std::tie(rhs.m_scheme, rhs.m_isV6, rhs.m_host, rhs.m_port, rhs.m_path); } + friend std::ostream& + operator<<(std::ostream& os, const FaceUri& uri) + { + uri.print(os); + return os; + } + private: std::string m_scheme; std::string m_host; std::string m_port; std::string m_path; bool m_isV6 = false; ///< whether to add [] around host when converting to string representation - - friend std::ostream& operator<<(std::ostream& os, const FaceUri& uri); }; -std::ostream& -operator<<(std::ostream& os, const FaceUri& uri); - } // namespace ndn #endif // NDN_CXX_NET_FACE_URI_HPP diff --git a/ndn-cxx/net/impl/netlink-socket.cpp b/ndn-cxx/net/impl/netlink-socket.cpp index b3f59f71..706cc6da 100644 --- a/ndn-cxx/net/impl/netlink-socket.cpp +++ b/ndn-cxx/net/impl/netlink-socket.cpp @@ -366,7 +366,7 @@ RtnlSocket::sendDumpRequest(uint16_t nlmsgType, const void* payload, size_t payl { alignas(NLMSG_ALIGNTO) nlmsghdr nlh; }; - static_assert(sizeof(RtnlMessageHeader) == NLMSG_HDRLEN, ""); + static_assert(sizeof(RtnlMessageHeader) == NLMSG_HDRLEN); auto hdr = make_shared(); hdr->nlh.nlmsg_len = sizeof(RtnlMessageHeader) + payloadLen; @@ -472,7 +472,7 @@ GenlSocket::sendRequest(uint16_t familyId, uint8_t command, alignas(NLMSG_ALIGNTO) nlmsghdr nlh; alignas(NLMSG_ALIGNTO) genlmsghdr genlh; }; - static_assert(sizeof(GenlMessageHeader) == NLMSG_SPACE(GENL_HDRLEN), ""); + static_assert(sizeof(GenlMessageHeader) == NLMSG_SPACE(GENL_HDRLEN)); auto hdr = make_shared(); hdr->nlh.nlmsg_len = sizeof(GenlMessageHeader) + payloadLen; diff --git a/ndn-cxx/prefix-announcement.cpp b/ndn-cxx/prefix-announcement.cpp index e718fc59..b1870bd2 100644 --- a/ndn-cxx/prefix-announcement.cpp +++ b/ndn-cxx/prefix-announcement.cpp @@ -24,9 +24,6 @@ namespace ndn { -static_assert(std::is_convertible_v, - "PrefixAnnouncement::Error must inherit from tlv::Error"); - PrefixAnnouncement::PrefixAnnouncement() = default; PrefixAnnouncement::PrefixAnnouncement(Data data) @@ -126,14 +123,6 @@ PrefixAnnouncement::getKeywordComponent() return nc; } -bool -operator==(const PrefixAnnouncement& lhs, const PrefixAnnouncement& rhs) -{ - return lhs.getAnnouncedName() == rhs.getAnnouncedName() && - lhs.getExpiration() == rhs.getExpiration() && - lhs.getValidityPeriod() == rhs.getValidityPeriod(); -} - std::ostream& operator<<(std::ostream& os, const PrefixAnnouncement& pa) { diff --git a/ndn-cxx/prefix-announcement.hpp b/ndn-cxx/prefix-announcement.hpp index 11c29bdc..e60bdbba 100644 --- a/ndn-cxx/prefix-announcement.hpp +++ b/ndn-cxx/prefix-announcement.hpp @@ -33,7 +33,7 @@ namespace ndn { * * \sa https://redmine.named-data.net/projects/nfd/wiki/PrefixAnnouncement */ -class PrefixAnnouncement +class PrefixAnnouncement : private boost::equality_comparable { public: class Error : public tlv::Error @@ -126,26 +126,31 @@ public: // static methods static const name::Component& getKeywordComponent(); +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. + + /** + * \brief Test whether two prefix announcements have the same name, expiration period, + * and validity period. + */ + friend bool + operator==(const PrefixAnnouncement& lhs, const PrefixAnnouncement& rhs) + { + return lhs.m_announcedName == rhs.m_announcedName && + lhs.m_expiration == rhs.m_expiration && + lhs.m_validity == rhs.m_validity; + } + private: - mutable std::optional m_data; Name m_announcedName; time::milliseconds m_expiration = 0_ms; std::optional m_validity; + + mutable std::optional m_data; }; -/** - * \brief Test whether two prefix announcements have the same name, expiration period, - * and validity period. - */ -bool -operator==(const PrefixAnnouncement& lhs, const PrefixAnnouncement& rhs); - -inline bool -operator!=(const PrefixAnnouncement& lhs, const PrefixAnnouncement& rhs) -{ - return !(lhs == rhs); -} - /** * \brief Print prefix announcement to a stream. * diff --git a/ndn-cxx/security/additional-description.hpp b/ndn-cxx/security/additional-description.hpp index 09fa9c6a..a125a788 100644 --- a/ndn-cxx/security/additional-description.hpp +++ b/ndn-cxx/security/additional-description.hpp @@ -33,7 +33,7 @@ namespace ndn::security { * @brief Represents an %AdditionalDescription TLV element. * @sa https://docs.named-data.net/NDN-packet-spec/0.3/certificate.html */ -class AdditionalDescription +class AdditionalDescription : private boost::equality_comparable { public: class Error : public tlv::Error @@ -107,9 +107,10 @@ public: void wireDecode(const Block& wire); -private: // EqualityComparable concept +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 AdditionalDescription& lhs, const AdditionalDescription& rhs) @@ -117,12 +118,6 @@ private: // EqualityComparable concept return lhs.m_info == rhs.m_info; } - friend bool - operator!=(const AdditionalDescription& lhs, const AdditionalDescription& rhs) - { - return lhs.m_info != rhs.m_info; - } - private: std::map m_info; diff --git a/ndn-cxx/security/key-chain.cpp b/ndn-cxx/security/key-chain.cpp index 16f6c421..5c23d0db 100644 --- a/ndn-cxx/security/key-chain.cpp +++ b/ndn-cxx/security/key-chain.cpp @@ -112,7 +112,7 @@ class KeyChain::Locator { public: [[nodiscard]] bool - empty() const + empty() const noexcept { return scheme.empty(); } @@ -124,7 +124,7 @@ public: } friend bool - operator==(const Locator& lhs, const Locator& rhs) + operator==(const Locator& lhs, const Locator& rhs) noexcept { return lhs.scheme == rhs.scheme && lhs.location == rhs.location; } diff --git a/ndn-cxx/security/pib/certificate-container.cpp b/ndn-cxx/security/pib/certificate-container.cpp index 873e37dd..1fb630d7 100644 --- a/ndn-cxx/security/pib/certificate-container.cpp +++ b/ndn-cxx/security/pib/certificate-container.cpp @@ -27,22 +27,8 @@ namespace ndn::security::pib { NDN_LOG_INIT(ndn.security.CertificateContainer); -CertificateContainer::const_iterator::const_iterator(NameSet::const_iterator it, - const CertificateContainer& container) noexcept - : m_it(it) - , m_container(&container) -{ -} - -Certificate -CertificateContainer::const_iterator::operator*() -{ - BOOST_ASSERT(m_container != nullptr); - return m_container->get(*m_it); -} - bool -CertificateContainer::const_iterator::operator==(const const_iterator& other) const +CertificateContainer::const_iterator::equals(const const_iterator& other) const noexcept { bool isThisEnd = m_container == nullptr || m_it == m_container->m_certNames.end(); bool isOtherEnd = other.m_container == nullptr || other.m_it == other.m_container->m_certNames.end(); diff --git a/ndn-cxx/security/pib/certificate-container.hpp b/ndn-cxx/security/pib/certificate-container.hpp index 7c984687..3cd4b948 100644 --- a/ndn-cxx/security/pib/certificate-container.hpp +++ b/ndn-cxx/security/pib/certificate-container.hpp @@ -24,7 +24,6 @@ #include "ndn-cxx/security/certificate.hpp" -#include #include #include @@ -46,19 +45,17 @@ private: using NameSet = std::set; public: - class const_iterator + class const_iterator : public boost::forward_iterator_helper { public: - using iterator_category = std::forward_iterator_tag; - using value_type = const Certificate; - using difference_type = std::ptrdiff_t; - using pointer = value_type*; - using reference = value_type&; - const_iterator() = default; Certificate - operator*(); + operator*() const + { + BOOST_ASSERT(m_container != nullptr); + return m_container->get(*m_it); + } const_iterator& operator++() @@ -67,25 +64,21 @@ public: return *this; } - const_iterator - operator++(int) + friend bool + operator==(const const_iterator& lhs, const const_iterator& rhs) noexcept { - const_iterator it(*this); - ++m_it; - return it; - } - - bool - operator==(const const_iterator& other) const; - - bool - operator!=(const const_iterator& other) const - { - return !this->operator==(other); + return lhs.equals(rhs); } private: - const_iterator(NameSet::const_iterator it, const CertificateContainer& container) noexcept; + const_iterator(NameSet::const_iterator it, const CertificateContainer& container) noexcept + : m_it(it) + , m_container(&container) + { + } + + bool + equals(const const_iterator& other) const noexcept; private: NameSet::const_iterator m_it; diff --git a/ndn-cxx/security/pib/identity-container.cpp b/ndn-cxx/security/pib/identity-container.cpp index 8d80b954..6458885d 100644 --- a/ndn-cxx/security/pib/identity-container.cpp +++ b/ndn-cxx/security/pib/identity-container.cpp @@ -28,22 +28,8 @@ namespace ndn::security::pib { NDN_LOG_INIT(ndn.security.IdentityContainer); -IdentityContainer::const_iterator::const_iterator(NameSet::const_iterator it, - const IdentityContainer& container) noexcept - : m_it(it) - , m_container(&container) -{ -} - -Identity -IdentityContainer::const_iterator::operator*() -{ - BOOST_ASSERT(m_container != nullptr); - return m_container->get(*m_it); -} - bool -IdentityContainer::const_iterator::operator==(const const_iterator& other) const +IdentityContainer::const_iterator::equals(const const_iterator& other) const noexcept { bool isThisEnd = m_container == nullptr || m_it == m_container->m_identityNames.end(); bool isOtherEnd = other.m_container == nullptr || other.m_it == other.m_container->m_identityNames.end(); diff --git a/ndn-cxx/security/pib/identity-container.hpp b/ndn-cxx/security/pib/identity-container.hpp index 786c7ba4..da844b1b 100644 --- a/ndn-cxx/security/pib/identity-container.hpp +++ b/ndn-cxx/security/pib/identity-container.hpp @@ -24,7 +24,6 @@ #include "ndn-cxx/security/pib/identity.hpp" -#include #include #include @@ -46,19 +45,17 @@ private: using NameSet = std::set; public: - class const_iterator + class const_iterator : public boost::forward_iterator_helper { public: - using iterator_category = std::forward_iterator_tag; - using value_type = const Identity; - using difference_type = std::ptrdiff_t; - using pointer = value_type*; - using reference = value_type&; - const_iterator() = default; Identity - operator*(); + operator*() const + { + BOOST_ASSERT(m_container != nullptr); + return m_container->get(*m_it); + } const_iterator& operator++() @@ -67,25 +64,21 @@ public: return *this; } - const_iterator - operator++(int) + friend bool + operator==(const const_iterator& lhs, const const_iterator& rhs) noexcept { - const_iterator it(*this); - ++m_it; - return it; - } - - bool - operator==(const const_iterator& other) const; - - bool - operator!=(const const_iterator& other) const - { - return !this->operator==(other); + return lhs.equals(rhs); } private: - const_iterator(NameSet::const_iterator it, const IdentityContainer& container) noexcept; + const_iterator(NameSet::const_iterator it, const IdentityContainer& container) noexcept + : m_it(it) + , m_container(&container) + { + } + + bool + equals(const const_iterator& other) const noexcept; private: NameSet::const_iterator m_it; diff --git a/ndn-cxx/security/pib/identity.hpp b/ndn-cxx/security/pib/identity.hpp index b39335b3..812bb3cc 100644 --- a/ndn-cxx/security/pib/identity.hpp +++ b/ndn-cxx/security/pib/identity.hpp @@ -40,7 +40,7 @@ class IdentityImpl; * name, and contains zero or more keys, at most one of which is set as the default key of that * identity. The properties of a key can be accessed after obtaining a Key object. */ -class Identity +class Identity : private boost::equality_comparable { public: /** @@ -154,19 +154,14 @@ private: // NOTE // The following "hidden friend" non-member operators are available // via argument-dependent lookup only and must be defined inline. + // boost::equality_comparable provides != operator. friend bool - operator==(const Identity& lhs, const Identity& rhs) + operator==(const Identity& lhs, const Identity& rhs) noexcept { return lhs.equals(rhs); } - friend bool - operator!=(const Identity& lhs, const Identity& rhs) - { - return !lhs.equals(rhs); - } - friend std::ostream& operator<<(std::ostream& os, const Identity& id) { diff --git a/ndn-cxx/security/pib/key-container.cpp b/ndn-cxx/security/pib/key-container.cpp index 94084cec..12cb64d9 100644 --- a/ndn-cxx/security/pib/key-container.cpp +++ b/ndn-cxx/security/pib/key-container.cpp @@ -28,22 +28,8 @@ namespace ndn::security::pib { NDN_LOG_INIT(ndn.security.KeyContainer); -KeyContainer::const_iterator::const_iterator(NameSet::const_iterator it, - const KeyContainer& container) noexcept - : m_it(it) - , m_container(&container) -{ -} - -Key -KeyContainer::const_iterator::operator*() -{ - BOOST_ASSERT(m_container != nullptr); - return m_container->get(*m_it); -} - bool -KeyContainer::const_iterator::operator==(const const_iterator& other) const +KeyContainer::const_iterator::equals(const const_iterator& other) const noexcept { bool isThisEnd = m_container == nullptr || m_it == m_container->m_keyNames.end(); bool isOtherEnd = other.m_container == nullptr || other.m_it == other.m_container->m_keyNames.end(); diff --git a/ndn-cxx/security/pib/key-container.hpp b/ndn-cxx/security/pib/key-container.hpp index 2b9b36cf..596ba411 100644 --- a/ndn-cxx/security/pib/key-container.hpp +++ b/ndn-cxx/security/pib/key-container.hpp @@ -24,7 +24,6 @@ #include "ndn-cxx/security/pib/key.hpp" -#include #include #include @@ -46,19 +45,17 @@ private: using NameSet = std::set; public: - class const_iterator + class const_iterator : public boost::forward_iterator_helper { public: - using iterator_category = std::forward_iterator_tag; - using value_type = const Key; - using difference_type = std::ptrdiff_t; - using pointer = value_type*; - using reference = value_type&; - const_iterator() = default; Key - operator*(); + operator*() const + { + BOOST_ASSERT(m_container != nullptr); + return m_container->get(*m_it); + } const_iterator& operator++() @@ -67,25 +64,21 @@ public: return *this; } - const_iterator - operator++(int) + friend bool + operator==(const const_iterator& lhs, const const_iterator& rhs) noexcept { - const_iterator it(*this); - ++m_it; - return it; - } - - bool - operator==(const const_iterator& other) const; - - bool - operator!=(const const_iterator& other) const - { - return !this->operator==(other); + return lhs.equals(rhs); } private: - const_iterator(NameSet::const_iterator it, const KeyContainer& container) noexcept; + const_iterator(NameSet::const_iterator it, const KeyContainer& container) noexcept + : m_it(it) + , m_container(&container) + { + } + + bool + equals(const const_iterator& other) const noexcept; private: NameSet::const_iterator m_it; diff --git a/ndn-cxx/security/pib/key.hpp b/ndn-cxx/security/pib/key.hpp index bd548fab..046aa589 100644 --- a/ndn-cxx/security/pib/key.hpp +++ b/ndn-cxx/security/pib/key.hpp @@ -41,7 +41,7 @@ class KeyImpl; * `//KEY/`, and contains one or more certificates, one of which is set as * default certificate of that key. Certificates can be directly accessed from a Key object. */ -class Key +class Key : private boost::equality_comparable { public: /** @@ -173,19 +173,14 @@ private: // NOTE // The following "hidden friend" non-member operators are available // via argument-dependent lookup only and must be defined inline. + // boost::equality_comparable provides != operator. friend bool - operator==(const Key& lhs, const Key& rhs) + operator==(const Key& lhs, const Key& rhs) noexcept { return lhs.equals(rhs); } - friend bool - operator!=(const Key& lhs, const Key& rhs) - { - return !lhs.equals(rhs); - } - friend std::ostream& operator<<(std::ostream& os, const Key& key) { diff --git a/ndn-cxx/security/transform/hex-decode.cpp b/ndn-cxx/security/transform/hex-decode.cpp index 9cbccf7c..97e67749 100644 --- a/ndn-cxx/security/transform/hex-decode.cpp +++ b/ndn-cxx/security/transform/hex-decode.cpp @@ -43,7 +43,7 @@ static const int8_t C2H[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 224-239 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 240-255 }; -static_assert(std::extent_v == 256, ""); +static_assert(std::extent_v == 256); HexDecode::HexDecode() diff --git a/ndn-cxx/security/transform/hex-encode.cpp b/ndn-cxx/security/transform/hex-encode.cpp index 0a9da8de..1dc759a4 100644 --- a/ndn-cxx/security/transform/hex-encode.cpp +++ b/ndn-cxx/security/transform/hex-encode.cpp @@ -27,13 +27,13 @@ static const uint8_t H2CL[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; -static_assert(std::extent_v == 16, ""); +static_assert(std::extent_v == 16); static const uint8_t H2CU[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; -static_assert(std::extent_v == 16, ""); +static_assert(std::extent_v == 16); HexEncode::HexEncode(bool useUpperCase) diff --git a/ndn-cxx/security/validity-period.hpp b/ndn-cxx/security/validity-period.hpp index f4da2f48..a4b204c5 100644 --- a/ndn-cxx/security/validity-period.hpp +++ b/ndn-cxx/security/validity-period.hpp @@ -32,7 +32,7 @@ namespace ndn::security { * @brief Represents a %ValidityPeriod TLV element. * @sa https://docs.named-data.net/NDN-packet-spec/0.3/certificate.html */ -class ValidityPeriod +class ValidityPeriod : private boost::equality_comparable { public: class Error : public tlv::Error @@ -135,21 +135,16 @@ private: static TimePoint decodeTimePoint(const Block& element); -private: // EqualityComparable concept +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 ValidityPeriod& lhs, const ValidityPeriod& rhs) { - return !(lhs != rhs); - } - - friend bool - operator!=(const ValidityPeriod& lhs, const ValidityPeriod& rhs) - { - return lhs.m_notBefore != rhs.m_notBefore || - lhs.m_notAfter != rhs.m_notAfter; + return lhs.m_notBefore == rhs.m_notBefore && + lhs.m_notAfter == rhs.m_notAfter; } private: diff --git a/ndn-cxx/util/backports.hpp b/ndn-cxx/util/backports.hpp index d9932f54..18c2c985 100644 --- a/ndn-cxx/util/backports.hpp +++ b/ndn-cxx/util/backports.hpp @@ -44,7 +44,7 @@ template to_underlying(T val) noexcept { // instantiating underlying_type with a non-enum type is UB before C++20 - static_assert(std::is_enum_v, ""); + static_assert(std::is_enum_v); return static_cast>(val); } #endif // __cpp_lib_to_underlying diff --git a/ndn-cxx/util/concepts.hpp b/ndn-cxx/util/concepts.hpp index bcd336d3..7cd71f6b 100644 --- a/ndn-cxx/util/concepts.hpp +++ b/ndn-cxx/util/concepts.hpp @@ -99,10 +99,10 @@ class NfdMgmtProtocolStruct : public WireEncodable public: BOOST_CONCEPT_USAGE(NfdMgmtProtocolStruct) { - static_assert(std::is_default_constructible_v, ""); - static_assert(boost::has_equal_to::value, ""); - static_assert(boost::has_not_equal_to::value, ""); - static_assert(boost::has_left_shift::value, ""); + static_assert(std::is_default_constructible_v); + static_assert(boost::has_equal_to::value); + static_assert(boost::has_not_equal_to::value); + static_assert(boost::has_left_shift::value); static_assert(std::is_convertible_v, "ndn::tlv::Error must be a public base of X::Error"); } diff --git a/ndn-cxx/util/scheduler.cpp b/ndn-cxx/util/scheduler.cpp index ecc9c7f6..fae2a846 100644 --- a/ndn-cxx/util/scheduler.cpp +++ b/ndn-cxx/util/scheduler.cpp @@ -67,12 +67,6 @@ EventId::reset() noexcept *this = {}; } -std::ostream& -operator<<(std::ostream& os, const EventId& eventId) -{ - return os << eventId.m_info.lock(); -} - bool Scheduler::EventQueueCompare::operator()(const shared_ptr& a, const shared_ptr& b) const noexcept diff --git a/ndn-cxx/util/scheduler.hpp b/ndn-cxx/util/scheduler.hpp index b5dd9087..e82b1517 100644 --- a/ndn-cxx/util/scheduler.hpp +++ b/ndn-cxx/util/scheduler.hpp @@ -26,7 +26,9 @@ #include "ndn-cxx/detail/cancel-handle.hpp" #include "ndn-cxx/util/time.hpp" +#include #include + #include namespace ndn { @@ -55,32 +57,40 @@ using EventCallback = std::function; * \warning Canceling an event after the scheduler has been destructed may trigger undefined * behavior. */ -class EventId : public detail::CancelHandle +class EventId : public detail::CancelHandle, private boost::equality_comparable { public: - /** \brief Constructs an empty EventId + /** + * \brief Constructs an empty EventId. */ EventId() noexcept = default; - /** \brief Determine whether the event is valid. - * \retval true The event is valid. - * \retval false This EventId is empty, or the event is expired or cancelled. + /** + * \brief Determine whether the associated event is valid. + * \retval true The event is valid. + * \retval false This EventId is empty, or the event is expired or cancelled. */ explicit operator bool() const noexcept; - /** \brief Clear this EventId without canceling. - * \post !(*this) + /** + * \brief Clear this EventId without canceling the associated event. + * \post !(*this) */ void reset() noexcept; private: + EventId(Scheduler& sched, weak_ptr info); + +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. - /** \brief Determine whether this and other refer to the same event, or are both - * empty/expired/cancelled. + /** + * \brief Determine whether \p lhs and \p rhs refer to the same event, or are both + * empty/expired/cancelled. */ friend bool operator==(const EventId& lhs, const EventId& rhs) noexcept @@ -90,25 +100,18 @@ private: !rhs.m_info.owner_before(lhs.m_info)); } - friend bool - operator!=(const EventId& lhs, const EventId& rhs) noexcept + friend std::ostream& + operator<<(std::ostream& os, const EventId& eventId) { - return !(lhs == rhs); + return os << eventId.m_info.lock(); } -private: - EventId(Scheduler& sched, weak_ptr info); - private: weak_ptr m_info; friend Scheduler; - friend std::ostream& operator<<(std::ostream& os, const EventId& eventId); }; -std::ostream& -operator<<(std::ostream& os, const EventId& eventId); - /** \brief A scoped handle for a scheduled event. * * Upon destruction of this handle, the event is canceled automatically. diff --git a/ndn-cxx/util/signal/connection.hpp b/ndn-cxx/util/signal/connection.hpp index 477d22c5..d27dcb24 100644 --- a/ndn-cxx/util/signal/connection.hpp +++ b/ndn-cxx/util/signal/connection.hpp @@ -24,6 +24,8 @@ #include "ndn-cxx/detail/common.hpp" +#include + namespace ndn::signal { using DisconnectFunction = std::function; @@ -32,22 +34,24 @@ using DisconnectFunction = std::function; * \brief Represents a connection to a signal. * \note This type is copyable. Any copy can be used to disconnect. */ -class Connection +class Connection : private boost::equality_comparable { public: constexpr Connection() noexcept = default; - /** \brief Disconnects from the signal. - * \note If the connection is already disconnected, or if the Signal has been destructed, - * this operation has no effect. - * \warning During signal emission, attempting to disconnect a connection other than - * the executing handler's own connection results in undefined behavior. + /** + * \brief Disconnects from the signal. + * \note If the connection is already disconnected, or if the Signal has been destructed, + * this operation has no effect. + * \warning During signal emission, attempting to disconnect a connection other than + * the executing handler's own connection results in undefined behavior. */ void disconnect(); - /** \brief Check if connected to the signal. + /** + * \brief Check if connected to the signal. */ bool isConnected() const noexcept @@ -56,22 +60,22 @@ public: } private: - /** \param disconnect weak_ptr to a function that disconnects the handler - */ explicit Connection(weak_ptr disconnect) noexcept; template friend class Signal; -private: +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. - /** \brief Compare for equality. + /** + * \brief Compare for equality. * - * Two connections are equal if they both refer to the same connection that isn't disconnected, - * or they are both disconnected. + * Two connections are equal if they both refer to the same connection that isn't disconnected, + * or they are both disconnected. */ friend bool operator==(const Connection& lhs, const Connection& rhs) noexcept @@ -81,12 +85,6 @@ private: !rhs.m_disconnect.owner_before(lhs.m_disconnect)); } - friend bool - operator!=(const Connection& lhs, const Connection& rhs) noexcept - { - return !(lhs == rhs); - } - private: /** \note The only shared_ptr to the disconnect function is stored in Signal<..>::Slot, * and will be destructed if the handler is disconnected (through another Connection diff --git a/tests/benchmarks/encoding-bench.cpp b/tests/benchmarks/encoding-bench.cpp index a3e0b5e5..7694d894 100644 --- a/tests/benchmarks/encoding-bench.cpp +++ b/tests/benchmarks/encoding-bench.cpp @@ -68,7 +68,7 @@ struct ReadVarNumberAlignTest : public ReadVarNumberTest { using AlignmentOffset = std::integral_constant; - static_assert(sizeof(ReadVarNumberTest::WIRE) == WIRE_SIZE, ""); + static_assert(sizeof(ReadVarNumberTest::WIRE) == WIRE_SIZE); }; using ReadVarNumberTests = boost::mpl::vector< @@ -97,7 +97,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(ReadVarNumber, Test, ReadVarNumberTests) constexpr int N_ITERATIONS = 100000000; alignas(8) uint8_t buffer[16]; - static_assert(Test::AlignmentOffset::value + sizeof(Test::WIRE) <= sizeof(buffer), ""); + static_assert(Test::AlignmentOffset::value + sizeof(Test::WIRE) <= sizeof(buffer)); uint8_t* const begin = buffer + Test::AlignmentOffset::value; std::memcpy(begin, Test::WIRE, sizeof(Test::WIRE)); const uint8_t* const end = begin + sizeof(Test::WIRE); diff --git a/tests/unit/face.t.cpp b/tests/unit/face.t.cpp index c4ae0260..f369d6f4 100644 --- a/tests/unit/face.t.cpp +++ b/tests/unit/face.t.cpp @@ -44,7 +44,7 @@ protected: : face(m_io, m_keyChain, {true, !std::is_same_v}) { static_assert(std::is_same_v || - std::is_same_v, ""); + std::is_same_v); } /** \brief Execute a prefix registration, and optionally check the name in callback. diff --git a/tests/unit/interest.t.cpp b/tests/unit/interest.t.cpp index bd6e3027..73b7beff 100644 --- a/tests/unit/interest.t.cpp +++ b/tests/unit/interest.t.cpp @@ -31,6 +31,7 @@ BOOST_CONCEPT_ASSERT((WireEncodableWithEncodingBuffer)); BOOST_CONCEPT_ASSERT((WireDecodable)); static_assert(std::is_convertible_v, "Interest::Error must inherit from tlv::Error"); +BOOST_CONCEPT_ASSERT((boost::EqualityComparable)); BOOST_AUTO_TEST_SUITE(TestInterest) diff --git a/tests/unit/metadata-object.t.cpp b/tests/unit/metadata-object.t.cpp index 480f7d40..0cbe7377 100644 --- a/tests/unit/metadata-object.t.cpp +++ b/tests/unit/metadata-object.t.cpp @@ -26,6 +26,9 @@ namespace ndn::tests { +static_assert(std::is_convertible_v, + "MetadataObject::Error must inherit from tlv::Error"); + class MetadataObjectFixture : public KeyChainFixture { public: diff --git a/tests/unit/name-component.t.cpp b/tests/unit/name-component.t.cpp index d72de0f5..d4b674d8 100644 --- a/tests/unit/name-component.t.cpp +++ b/tests/unit/name-component.t.cpp @@ -35,7 +35,9 @@ namespace ndn::tests { using ndn::name::Component; using ndn::name::UriFormat; +static_assert(sizeof(Component) == sizeof(Block)); BOOST_CONCEPT_ASSERT((boost::EqualityComparable)); +BOOST_CONCEPT_ASSERT((boost::Comparable)); BOOST_CONCEPT_ASSERT((WireEncodable)); BOOST_CONCEPT_ASSERT((WireEncodableWithEncodingBuffer)); BOOST_CONCEPT_ASSERT((WireDecodable)); diff --git a/tests/unit/name.t.cpp b/tests/unit/name.t.cpp index da95aedf..734edb7d 100644 --- a/tests/unit/name.t.cpp +++ b/tests/unit/name.t.cpp @@ -31,6 +31,7 @@ namespace ndn::tests { using ndn::name::Component; BOOST_CONCEPT_ASSERT((boost::EqualityComparable)); +BOOST_CONCEPT_ASSERT((boost::Comparable)); BOOST_CONCEPT_ASSERT((WireEncodable)); BOOST_CONCEPT_ASSERT((WireEncodableWithEncodingBuffer)); BOOST_CONCEPT_ASSERT((WireDecodable)); diff --git a/tests/unit/prefix-announcement.t.cpp b/tests/unit/prefix-announcement.t.cpp index a13e9f53..a36f0842 100644 --- a/tests/unit/prefix-announcement.t.cpp +++ b/tests/unit/prefix-announcement.t.cpp @@ -27,6 +27,10 @@ namespace ndn::tests { +BOOST_CONCEPT_ASSERT((boost::EqualityComparable)); +static_assert(std::is_convertible_v, + "PrefixAnnouncement::Error must inherit from tlv::Error"); + BOOST_AUTO_TEST_SUITE(TestPrefixAnnouncement) static Data diff --git a/tests/unit/security/pib/identity.t.cpp b/tests/unit/security/pib/identity.t.cpp index 70252d9b..42a99167 100644 --- a/tests/unit/security/pib/identity.t.cpp +++ b/tests/unit/security/pib/identity.t.cpp @@ -29,6 +29,8 @@ namespace ndn::tests { using namespace ndn::security::pib; +BOOST_CONCEPT_ASSERT((boost::EqualityComparable)); + BOOST_AUTO_TEST_SUITE(Security) BOOST_FIXTURE_TEST_SUITE(TestIdentity, PibDataFixture) diff --git a/tests/unit/security/pib/key.t.cpp b/tests/unit/security/pib/key.t.cpp index 5273436c..a3c18061 100644 --- a/tests/unit/security/pib/key.t.cpp +++ b/tests/unit/security/pib/key.t.cpp @@ -29,6 +29,8 @@ namespace ndn::tests { using namespace ndn::security::pib; +BOOST_CONCEPT_ASSERT((boost::EqualityComparable)); + BOOST_AUTO_TEST_SUITE(Security) BOOST_FIXTURE_TEST_SUITE(TestKey, PibDataFixture) diff --git a/tests/unit/util/ostream-joiner.t.cpp b/tests/unit/util/ostream-joiner.t.cpp index 2e7ac8f3..4ac33817 100644 --- a/tests/unit/util/ostream-joiner.t.cpp +++ b/tests/unit/util/ostream-joiner.t.cpp @@ -37,7 +37,7 @@ BOOST_AUTO_TEST_CASE(Basic) auto joiner1 = ostream_joiner(os, ' '); auto joiner2 = make_ostream_joiner(os, ' '); - static_assert(std::is_same_v, ""); + static_assert(std::is_same_v); std::vector v(5); std::iota(v.begin(), v.end(), 1); diff --git a/tests/unit/version.t.cpp b/tests/unit/version.t.cpp index 527bc957..4b551a9c 100644 --- a/tests/unit/version.t.cpp +++ b/tests/unit/version.t.cpp @@ -37,9 +37,9 @@ BOOST_AUTO_TEST_CASE(VersionNumber) NDN_CXX_VERSION_MINOR * 1000 + NDN_CXX_VERSION_PATCH); - static_assert(NDN_CXX_VERSION_MAJOR < 1000, ""); - static_assert(NDN_CXX_VERSION_MINOR < 1000, ""); - static_assert(NDN_CXX_VERSION_PATCH < 1000, ""); + static_assert(NDN_CXX_VERSION_MAJOR < 1000); + static_assert(NDN_CXX_VERSION_MINOR < 1000); + static_assert(NDN_CXX_VERSION_PATCH < 1000); } BOOST_AUTO_TEST_CASE(VersionString)