X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FProtocols%2FBSDSocketAddress.hh;h=2040513e11bea285fe93c49acbfc0dfa0376c6ad;hb=5443435c4c2b6e4386c5334b5b8358273f2bae93;hp=1e7d1e7737983cd81094594714a4de92d46ff578;hpb=7baaacae27c02c86ceda5c7ee41d3172d1e23ffa;p=senf.git diff --git a/Socket/Protocols/BSDSocketAddress.hh b/Socket/Protocols/BSDSocketAddress.hh index 1e7d1e7..2040513 100644 --- a/Socket/Protocols/BSDSocketAddress.hh +++ b/Socket/Protocols/BSDSocketAddress.hh @@ -23,10 +23,13 @@ /** \file \brief BSDSocketAddress public header */ -#ifndef HH_BSDSocketAddress_ -#define HH_BSDSocketAddress_ 1 +#ifndef HH_SENF_Socket_Protocols_BSDSocketAddress_ +#define HH_SENF_Socket_Protocols_BSDSocketAddress_ 1 // Custom includes +#include +#include +#include #include "../../Utils/safe_bool.hh" #include #include @@ -71,14 +74,19 @@ namespace senf { \ingroup addr_group */ class BSDSocketAddress - : public senf::comparable_safe_bool + : public senf::comparable_safe_bool, + public boost::less_than_comparable, + public boost::equality_comparable { public: bool operator==(BSDSocketAddress const & other) const; ///< Compare two arbitrary addresses /**< For addresses to be considered equal, they must have the same family, length and the data must be identical. */ - bool operator!=(BSDSocketAddress const & other) const; ///< Inverse of operator== + bool operator<(BSDSocketAddress const & other) const; ///< Compare two arbitrary addresses + /**< Ordering is based on the in-memory representation. It + is primarily useful to use addresses as keys in a map + or set. */ bool boolean_test() const; ///< Return \c true, if address is not empty /**< An address is considered empty if @@ -112,8 +120,15 @@ namespace senf { void socklen(socklen_t len); private: - - socklen_t len_; + // The following incantation is needed to fix the alignment of the sockaddr data members + // which will be added by the derived classes later: The alignment must be forced + // to coincide with the struct sockaddr_storage alignment (which must have the largest + // alignment of all sockaddr types). + union { + socklen_t len_; + boost::type_with_alignment::value> a_; + char _b[boost::alignment_of::value]; + }; }; /** \brief Safe socket address down-cast