This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Make basic_resolver_entry<> operators inline friend


I am not yet sending this to gcc-patches because I am quite sceptical on the approval.

While running tests with versioned namespace enabled those 2 tests are failing:

experimental/net/internet/resolver/ops/lookup.cc
experimental/net/internet/resolver/ops/reverse.cc

This is because basic_resolver_entry<> == operator is using basic_resolver_entry<>::host_name or service_name which expect a C++11 basic_string with the copy allocator aware constructor. But I haven't enable C++11 abi string so the compilation error.

I don't know if the COW string implementation is supposed to have this constructor but another way to fix those tests is to avoid those members. By making operators friend we can access members directly and so avoid the copy.

And yes, I also like inline friend operators :-)

What do you think ?

François


diff --git a/libstdc++-v3/include/experimental/internet b/libstdc++-v3/include/experimental/internet
index 5e1dbb834db..e715fda163e 100644
--- a/libstdc++-v3/include/experimental/internet
+++ b/libstdc++-v3/include/experimental/internet
@@ -1597,23 +1597,21 @@ namespace ip
       basic_endpoint<_InternetProtocol> _M_ep;
       string _M_host;
       string _M_svc;
-    };
 
-  template<typename _InternetProtocol>
-    inline bool
-    operator==(const basic_resolver_entry<_InternetProtocol>& __a,
-	       const basic_resolver_entry<_InternetProtocol>& __b)
-    {
-      return __a.endpoint() == __b.endpoint()
-	&& __a.host_name() == __b.host_name()
-	&& __a.service_name() == __b.service_name();
-    }
+      friend bool
+      operator==(const basic_resolver_entry& __a,
+		 const basic_resolver_entry& __b)
+      {
+	return __a._M_ep == __b._M_ep
+	  && __a._M_host == __b._M_host
+	  && __a._M_svc == __b._M_svc;
+      }
 
-  template<typename _InternetProtocol>
-    inline bool
-    operator!=(const basic_resolver_entry<_InternetProtocol>& __a,
-	       const basic_resolver_entry<_InternetProtocol>& __b)
-    { return !(__a == __b); }
+      friend bool
+      operator!=(const basic_resolver_entry& __a,
+		 const basic_resolver_entry& __b)
+      { return !(__a == __b); }
+  };
 
   // @}
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]