qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject qpid-proton git commit: NO-JIRA: c++: fix ambiguous template compile error on windows, caused by template operator !=.
Date Sat, 23 Jan 2016 16:36:41 GMT
Repository: qpid-proton
Updated Branches:
  refs/heads/winfix [created] e39baba53


NO-JIRA: c++: fix ambiguous template compile error on windows, caused by template operator
!=.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/e39baba5
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/e39baba5
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/e39baba5

Branch: refs/heads/winfix
Commit: e39baba53694f1d82e86d7909b6a8619b39d44b5
Parents: 103b312
Author: Alan Conway <aconway@redhat.com>
Authored: Sat Jan 23 11:35:38 2016 -0500
Committer: Alan Conway <aconway@redhat.com>
Committed: Sat Jan 23 11:35:38 2016 -0500

----------------------------------------------------------------------
 .../bindings/cpp/include/proton/comparable.hpp  | 49 ++++++++++++++++++++
 .../bindings/cpp/include/proton/duration.hpp    |  3 +-
 .../bindings/cpp/include/proton/endpoint.hpp    |  4 +-
 proton-c/bindings/cpp/include/proton/object.hpp |  6 +--
 proton-c/bindings/cpp/include/proton/scalar.hpp |  6 ++-
 proton-c/bindings/cpp/include/proton/types.hpp  | 12 ++---
 proton-c/bindings/cpp/include/proton/value.hpp  |  2 +-
 7 files changed, 65 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e39baba5/proton-c/bindings/cpp/include/proton/comparable.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/comparable.hpp b/proton-c/bindings/cpp/include/proton/comparable.hpp
new file mode 100644
index 0000000..6871b31
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/comparable.hpp
@@ -0,0 +1,49 @@
+#ifndef COMPARABLE_HPP
+#define COMPARABLE_HPP
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+///@cond INTERNAL
+namespace proton {
+
+/// Base class for comparable types with operator< and operator==. Provides remaining
operators.
+template <class T> class comparable {};
+
+template <class T> bool operator>(const comparable<T> &a, const comparable<T>
&b) {
+    return static_cast<const T&>(b) < static_cast<const T&>(a);
+}
+
+template <class T> bool operator<=(const comparable<T> &a, const comparable<T>
&b) {
+    return !(static_cast<const T&>(a) > static_cast<const T&>(b));
+}
+
+template <class T> bool operator>=(const comparable<T> &a, const comparable<T>
&b) {
+    return !(static_cast<const T&>(a) < static_cast<const T&>(b));
+}
+
+template <class T> bool operator!=(const comparable<T> &a, const comparable<T>
&b) {
+    return !(static_cast<const T&>(a) == static_cast<const T&>(b));
+}
+
+}
+
+///@endcond
+
+#endif // COMPARABLE_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e39baba5/proton-c/bindings/cpp/include/proton/duration.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/duration.hpp b/proton-c/bindings/cpp/include/proton/duration.hpp
index 3d9b823..1726701 100644
--- a/proton-c/bindings/cpp/include/proton/duration.hpp
+++ b/proton-c/bindings/cpp/include/proton/duration.hpp
@@ -24,11 +24,12 @@
 
 #include "proton/export.hpp"
 #include "proton/types.hpp"
+#include "proton/comparable.hpp"
 
 namespace proton {
 
 /** Duration in milliseconds. */
-class duration
+class duration : public comparable<duration>
 {
   public:
     uint64_t milliseconds;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e39baba5/proton-c/bindings/cpp/include/proton/endpoint.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/endpoint.hpp b/proton-c/bindings/cpp/include/proton/endpoint.hpp
index 529a60b..b440512 100644
--- a/proton-c/bindings/cpp/include/proton/endpoint.hpp
+++ b/proton-c/bindings/cpp/include/proton/endpoint.hpp
@@ -23,6 +23,7 @@
  */
 #include "proton/export.hpp"
 #include "proton/connection.h"
+#include "proton/comparable.hpp"
 
 namespace proton {
 
@@ -63,7 +64,8 @@ class endpoint
 };
 
 ///@cond INTERNAL
-template <class T> class iter_base {
+
+template <class T> class iter_base  : public comparable<iter_base<T> >
{
   public:
     typedef T value_type;
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e39baba5/proton-c/bindings/cpp/include/proton/object.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/object.hpp b/proton-c/bindings/cpp/include/proton/object.hpp
index 32bc086..1f2032b 100644
--- a/proton-c/bindings/cpp/include/proton/object.hpp
+++ b/proton-c/bindings/cpp/include/proton/object.hpp
@@ -21,7 +21,7 @@
 
 #include "proton/config.hpp"
 #include "proton/export.hpp"
-
+#include "proton/comparable.hpp"
 #include <memory>
 
 namespace proton {
@@ -33,7 +33,7 @@ class pn_ptr_base {
     PN_CPP_EXTERN static void decref(void* p);
 };
 
-template <class T> class pn_ptr : private pn_ptr_base {
+template <class T> class pn_ptr : private pn_ptr_base, public comparable<pn_ptr<T>
> {
   public:
     pn_ptr() : ptr_(0) {}
     pn_ptr(T* p) : ptr_(p) { incref(ptr_); }
@@ -70,7 +70,7 @@ template <class T> pn_ptr<T> take_ownership(T* p) { return pn_ptr<T>::take_owner
 /**
  * Base class for proton object types
  */
-template <class T> class object {
+template <class T> class object : public comparable<object<T> > {
   public:
     bool operator!() const { return !object_; }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e39baba5/proton-c/bindings/cpp/include/proton/scalar.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/scalar.hpp b/proton-c/bindings/cpp/include/proton/scalar.hpp
index d135ab6..c06a675 100644
--- a/proton-c/bindings/cpp/include/proton/scalar.hpp
+++ b/proton-c/bindings/cpp/include/proton/scalar.hpp
@@ -19,7 +19,9 @@
  * under the License.
  */
 
+#include "proton/comparable.hpp"
 #include "proton/types.hpp"
+
 #include <iosfwd>
 #include <string>
 
@@ -29,7 +31,7 @@ class encoder;
 class decoder;
 
 /** scalar holds an instance of any scalar AMQP type. */
-class scalar {
+class scalar : public comparable<scalar> {
   public:
     PN_CPP_EXTERN scalar();
     PN_CPP_EXTERN scalar(const scalar&);
@@ -130,7 +132,7 @@ class scalar {
 };
 
 ///@internal base for restricted scalar types
-class restricted_scalar {
+class restricted_scalar : public comparable<restricted_scalar> {
   public:
     operator const scalar&() const { return scalar_; }
     type_id type() const { return scalar_.type(); }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e39baba5/proton-c/bindings/cpp/include/proton/types.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/types.hpp b/proton-c/bindings/cpp/include/proton/types.hpp
index d0f3da6..32a2fca 100644
--- a/proton-c/bindings/cpp/include/proton/types.hpp
+++ b/proton-c/bindings/cpp/include/proton/types.hpp
@@ -23,6 +23,7 @@
  * Defines C++ types representing AMQP types.
  */
 
+#include "proton/comparable.hpp"
 #include "proton/export.hpp"
 #include "proton/error.hpp"
 
@@ -79,14 +80,7 @@ struct type_error : public decode_error {
     type_id got;  ///< Actual type_id
 };
 
-
 ///@cond INTERNAL
-/// Provide a full set of comparison operators for proton:: types that have < and ==.
-template <class T> bool operator>(const T &a, const T &b) { return b <
a; }
-template <class T> bool operator<=(const T &a, const T &b) { return !(a
> b); }
-template <class T> bool operator>=(const T &a, const T &b) { return !(a
< b); }
-template <class T> bool operator!=(const T &a, const T &b) { return !(a ==
b); }
-
 PN_CPP_EXTERN pn_bytes_t pn_bytes(const std::string&);
 PN_CPP_EXTERN std::string str(const pn_bytes_t& b);
 ///@endcond
@@ -140,7 +134,7 @@ struct amqp_binary : public std::string {
 };
 
 /// Template for opaque proton proton types that can be treated as byte arrays.
-template <class P> struct opaque {
+template <class P> struct opaque : public comparable<opaque<P> > {
     P value;
     opaque(const P& p=P()) : value(p) {}
     operator P() const { return value; }
@@ -171,7 +165,7 @@ typedef opaque<pn_decimal128_t> amqp_decimal128;
 PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const amqp_decimal128&);
 
 /// AMQP timestamp, milliseconds since the epoch 00:00:00 (UTC), 1 January 1970.
-struct amqp_timestamp {
+struct amqp_timestamp : public comparable<amqp_timestamp> {
     pn_timestamp_t milliseconds;
     amqp_timestamp(::int64_t ms=0) : milliseconds(ms) {}
     operator pn_timestamp_t() const { return milliseconds; }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e39baba5/proton-c/bindings/cpp/include/proton/value.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/value.hpp b/proton-c/bindings/cpp/include/proton/value.hpp
index b6ea4d2..732763c 100644
--- a/proton-c/bindings/cpp/include/proton/value.hpp
+++ b/proton-c/bindings/cpp/include/proton/value.hpp
@@ -31,7 +31,7 @@ namespace proton {
  * from native C++ types.
  *
  */
-class value {
+class value : public comparable<value> {
   public:
     PN_CPP_EXTERN value();
     PN_CPP_EXTERN value(const value&);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message