This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit f1b9ee0fc69d0836053f1f2c03a72861f787990a
Author: Andrew Stitcher <[email protected]>
AuthorDate: Mon Jan 17 23:27:24 2022 -0500

    PROTON-2485: Improve constructors/destructors using C++ 11 features
    
    Used '= default' where relevant and improved proton::binary and
    proton::symbol by inheriting the constructors of their parent classes.
---
 cpp/include/proton/annotation_key.hpp  |  2 +-
 cpp/include/proton/binary.hpp          |  7 +++----
 cpp/include/proton/delivery.hpp        |  2 +-
 cpp/include/proton/error_condition.hpp |  2 +-
 cpp/include/proton/message_id.hpp      |  2 +-
 cpp/include/proton/null.hpp            |  2 +-
 cpp/include/proton/receiver.hpp        |  2 +-
 cpp/include/proton/returned.hpp        |  2 +-
 cpp/include/proton/scalar.hpp          |  2 +-
 cpp/include/proton/sender.hpp          |  2 +-
 cpp/include/proton/source.hpp          |  2 +-
 cpp/include/proton/symbol.hpp          | 11 +++++------
 cpp/include/proton/target.hpp          |  2 +-
 cpp/include/proton/tracker.hpp         |  2 +-
 cpp/include/proton/work_queue.hpp      | 14 +++++++-------
 cpp/src/connection.cpp                 |  2 +-
 cpp/src/connection_options.cpp         |  2 +-
 cpp/src/container.cpp                  |  2 +-
 cpp/src/delivery.cpp                   |  2 +-
 cpp/src/endpoint.cpp                   |  2 +-
 cpp/src/error.cpp                      |  6 +++---
 cpp/src/handler.cpp                    |  4 ++--
 cpp/src/listener.cpp                   |  4 ++--
 cpp/src/map.cpp                        |  4 ++--
 cpp/src/node_options.cpp               |  4 ++--
 cpp/src/receiver.cpp                   |  2 +-
 cpp/src/receiver_options.cpp           |  2 +-
 cpp/src/reconnect_options.cpp          |  2 +-
 cpp/src/sender.cpp                     |  2 +-
 cpp/src/sender_options.cpp             |  2 +-
 cpp/src/session.cpp                    |  2 +-
 cpp/src/session_options.cpp            |  2 +-
 cpp/src/url.cpp                        |  2 +-
 cpp/src/value.cpp                      |  2 +-
 cpp/src/work_queue.cpp                 |  4 ++--
 35 files changed, 54 insertions(+), 56 deletions(-)

diff --git a/cpp/include/proton/annotation_key.hpp 
b/cpp/include/proton/annotation_key.hpp
index f9cc129..e6e93b0 100644
--- a/cpp/include/proton/annotation_key.hpp
+++ b/cpp/include/proton/annotation_key.hpp
@@ -38,7 +38,7 @@ namespace proton {
 class annotation_key : public scalar_base {
   public:
     /// An empty annotation key.
-    annotation_key() {}
+    annotation_key() = default;
 
     /// Construct from any type that can be assigned.
     template <class T> annotation_key(const T& x) { *this = x; }
diff --git a/cpp/include/proton/binary.hpp b/cpp/include/proton/binary.hpp
index e2a8ebc..f7396f6 100644
--- a/cpp/include/proton/binary.hpp
+++ b/cpp/include/proton/binary.hpp
@@ -41,11 +41,10 @@ class binary : public std::vector<uint8_t> {
   public:
     /// @name Constructors
     /// @{
-    explicit binary() : std::vector<value_type>() {}
-    explicit binary(size_t n) : std::vector<value_type>(n) {}
-    explicit binary(size_t n, value_type x) : std::vector<value_type>(n, x) {}
+    explicit binary() = default;
+    using std::vector<value_type>::vector;
+    explicit binary(const std::vector<value_type>& v) : 
std::vector<value_type>(v) {}
     explicit binary(const std::string& s) : std::vector<value_type>(s.begin(), 
s.end()) {}
-    template <class Iter> binary(Iter first, Iter last) : 
std::vector<value_type>(first, last) {}
     /// @}
 
     /// Convert to std::string
diff --git a/cpp/include/proton/delivery.hpp b/cpp/include/proton/delivery.hpp
index 4c4979b..4c4ac03 100644
--- a/cpp/include/proton/delivery.hpp
+++ b/cpp/include/proton/delivery.hpp
@@ -43,7 +43,7 @@ class delivery : public transfer {
     /// @endcond
 
   public:
-    delivery() {}
+    delivery() = default;
 
     PN_CPP_EXTERN ~delivery();
 
diff --git a/cpp/include/proton/error_condition.hpp 
b/cpp/include/proton/error_condition.hpp
index 9ab58e6..1e571cd 100644
--- a/cpp/include/proton/error_condition.hpp
+++ b/cpp/include/proton/error_condition.hpp
@@ -43,7 +43,7 @@ class error_condition {
 
   public:
     /// Create an empty error condition.
-    error_condition() {}
+    error_condition() = default;
 
     /// Create an error condition with only a description. A default
     /// name will be used ("proton:io:error").
diff --git a/cpp/include/proton/message_id.hpp 
b/cpp/include/proton/message_id.hpp
index 517a6b0..2edcc23 100644
--- a/cpp/include/proton/message_id.hpp
+++ b/cpp/include/proton/message_id.hpp
@@ -47,7 +47,7 @@ namespace proton {
 class message_id : public scalar_base {
   public:
     /// An empty message_id.
-    message_id() {}
+    message_id() = default;
 
     /// Construct from any type that can be assigned.
     template <class T> message_id(const T& x) { *this = x; }
diff --git a/cpp/include/proton/null.hpp b/cpp/include/proton/null.hpp
index f12cc03..01e4f3e 100644
--- a/cpp/include/proton/null.hpp
+++ b/cpp/include/proton/null.hpp
@@ -37,7 +37,7 @@ namespace proton {
 /// @see @ref types_page
 class null : private internal::comparable<null> {
   public:
-    null() {}
+    null() = default;
     /// Constructed from nullptr literal
     null(decltype(nullptr)) {}
 
diff --git a/cpp/include/proton/receiver.hpp b/cpp/include/proton/receiver.hpp
index 8643704..353f1d2 100644
--- a/cpp/include/proton/receiver.hpp
+++ b/cpp/include/proton/receiver.hpp
@@ -45,7 +45,7 @@ PN_CPP_CLASS_EXTERN receiver : public link {
 
   public:
     /// Create an empty receiver.
-    receiver() {}
+    receiver() = default;
 
     PN_CPP_EXTERN ~receiver();
 
diff --git a/cpp/include/proton/returned.hpp b/cpp/include/proton/returned.hpp
index 52ecba7..77e3cce 100644
--- a/cpp/include/proton/returned.hpp
+++ b/cpp/include/proton/returned.hpp
@@ -61,7 +61,7 @@ class PN_CPP_CLASS_EXTERN returned {
   private:
     typename T::pn_type* ptr_;
     returned(typename T::pn_type*);
-    returned& operator=(const returned&); // Not defined
+    returned& operator=(const returned&) = delete;
   friend class internal::returned_factory;
 };
 
diff --git a/cpp/include/proton/scalar.hpp b/cpp/include/proton/scalar.hpp
index b1dd8b1..9f6e456 100644
--- a/cpp/include/proton/scalar.hpp
+++ b/cpp/include/proton/scalar.hpp
@@ -37,7 +37,7 @@ namespace proton {
 class scalar : public scalar_base {
   public:
     /// Create an empty scalar.
-    PN_CPP_EXTERN scalar() {}
+    PN_CPP_EXTERN scalar() = default;
 
     /// Construct from any scalar type.
     template <class T> scalar(const T& x) { *this = x; }
diff --git a/cpp/include/proton/sender.hpp b/cpp/include/proton/sender.hpp
index 8685b58..59fd74b 100644
--- a/cpp/include/proton/sender.hpp
+++ b/cpp/include/proton/sender.hpp
@@ -44,7 +44,7 @@ PN_CPP_CLASS_EXTERN sender : public link {
 
   public:
     /// Create an empty sender.
-    sender() {}
+    sender() = default;
 
     PN_CPP_EXTERN ~sender();
 
diff --git a/cpp/include/proton/source.hpp b/cpp/include/proton/source.hpp
index 18b5ed7..76768c2 100644
--- a/cpp/include/proton/source.hpp
+++ b/cpp/include/proton/source.hpp
@@ -48,7 +48,7 @@ class source : public terminus {
     typedef map<symbol, value> filter_map;
 
     /// Create an empty source.
-    source() : terminus() {}
+    source() = default;
 
     /// The policy for distributing messages.
     enum distribution_mode {
diff --git a/cpp/include/proton/symbol.hpp b/cpp/include/proton/symbol.hpp
index e1847ba..5e36ac0 100644
--- a/cpp/include/proton/symbol.hpp
+++ b/cpp/include/proton/symbol.hpp
@@ -34,14 +34,13 @@ namespace proton {
 /// A symbol can contain only 7-bit ASCII characters.
 class symbol : public std::string {
   public:
-    /// Construct from a `std::string`.
-    symbol(const std::string& s=std::string()) : std::string(s) {}
+    symbol() = default;
 
-    /// Construct from a C string.
-    symbol(const char* s) : std::string(s) {}
+    /// Inherit all std::string constructors
+    using std::string::string;
 
-    /// Construct from any sequence of `char`.
-    template<class Iter> symbol(Iter start, Iter finish) : std::string(start, 
finish) {}
+    /// Construct from a `std::string`.
+    symbol(const std::string& s) : std::string(s) {}
 };
 
 } // proton
diff --git a/cpp/include/proton/target.hpp b/cpp/include/proton/target.hpp
index 448a340..4bf3a4c 100644
--- a/cpp/include/proton/target.hpp
+++ b/cpp/include/proton/target.hpp
@@ -45,7 +45,7 @@ template <class T> class factory;
 class target : public terminus {
   public:
     /// Create an empty target.
-    target() : terminus() {}
+    target() = default;
 
     using terminus::durability_mode;
     using terminus::expiry_policy;
diff --git a/cpp/include/proton/tracker.hpp b/cpp/include/proton/tracker.hpp
index 1dabf8b..3d8ad0a 100644
--- a/cpp/include/proton/tracker.hpp
+++ b/cpp/include/proton/tracker.hpp
@@ -45,7 +45,7 @@ class tracker : public transfer {
 
   public:
     /// Create an empty tracker.
-    tracker() {}
+    tracker() = default;
 
     /// Get the sender for this tracker.
     PN_CPP_EXTERN class sender sender() const;
diff --git a/cpp/include/proton/work_queue.hpp 
b/cpp/include/proton/work_queue.hpp
index 4f4a1d0..e917fa3 100644
--- a/cpp/include/proton/work_queue.hpp
+++ b/cpp/include/proton/work_queue.hpp
@@ -46,8 +46,8 @@ namespace proton {
 namespace internal { namespace v03 {
 
 struct invocable {
-    invocable() {}
-    virtual ~invocable() {}
+    invocable() = default;
+    virtual ~invocable() = default;
 
     virtual invocable& clone() const = 0;
     virtual void operator() () = 0;
@@ -55,7 +55,7 @@ struct invocable {
 
 template <class T>
 struct invocable_cloner : invocable {
-    virtual ~invocable_cloner() {}
+    virtual ~invocable_cloner() = default;
     virtual invocable& clone() const {
         return *new T(static_cast<T const&>(*this));
     }
@@ -86,14 +86,14 @@ struct invocable_wrapper {
 class work {
   public:
     /// Create a work item.
-    work() {}
+    work() = default;
 
     work(const invocable& i): item_(i) {}
 
     /// Invoke the work item.
     void operator()() { item_(); }
 
-    ~work() {}
+    ~work() = default;
 
   private:
     invocable_wrapper item_;
@@ -264,7 +264,7 @@ namespace internal { namespace v11 {
 class work {
   public:
     /// **Unsettled API**
-    work() {}
+    work() = default;
 
     /// **Unsettled API**
     ///
@@ -282,7 +282,7 @@ class work {
     /// Execute the piece of work
     void operator()() { item_(); }
 
-    ~work() {}
+    ~work() = default;
 
   private:
     std::function<void()> item_;
diff --git a/cpp/src/connection.cpp b/cpp/src/connection.cpp
index cf608a0..7d6c18d 100644
--- a/cpp/src/connection.cpp
+++ b/cpp/src/connection.cpp
@@ -46,7 +46,7 @@
 
 namespace proton {
 
-connection::~connection() {}
+connection::~connection() = default;
 
 transport connection::transport() const {
     return make_wrapper(pn_connection_transport(pn_object()));
diff --git a/cpp/src/connection_options.cpp b/cpp/src/connection_options.cpp
index 2ee550e..a04b699 100644
--- a/cpp/src/connection_options.cpp
+++ b/cpp/src/connection_options.cpp
@@ -221,7 +221,7 @@ connection_options::connection_options(const 
connection_options& x) : impl_(new
     *this = x;
 }
 
-connection_options::~connection_options() {}
+connection_options::~connection_options() = default;
 
 connection_options& connection_options::operator=(const connection_options& x) 
{
     *impl_ = *x.impl_;
diff --git a/cpp/src/container.cpp b/cpp/src/container.cpp
index 494ece8..07972aa 100644
--- a/cpp/src/container.cpp
+++ b/cpp/src/container.cpp
@@ -39,7 +39,7 @@ container::container(const std::string& id) :
     impl_(new impl(*this, id)) {}
 container::container() :
     impl_(new impl(*this, uuid::random().str())) {}
-container::~container() {}
+container::~container() = default;
 
 returned<connection> container::connect(const std::string &url) {
     return connect(url, connection_options());
diff --git a/cpp/src/delivery.cpp b/cpp/src/delivery.cpp
index a9d472a..8dc050e 100644
--- a/cpp/src/delivery.cpp
+++ b/cpp/src/delivery.cpp
@@ -45,7 +45,7 @@ namespace proton {
 delivery::delivery(pn_delivery_t* d): transfer(make_wrapper(d)) {}
 receiver delivery::receiver() const { return make_wrapper<class 
receiver>(pn_delivery_link(pn_object())); }
 binary delivery::tag() const { return bin(pn_delivery_tag(pn_object())); }
-delivery::~delivery() {}
+delivery::~delivery() = default;
 void delivery::accept() { settle_delivery(pn_object(), ACCEPTED); }
 void delivery::reject() { settle_delivery(pn_object(), REJECTED); }
 void delivery::release() { settle_delivery(pn_object(), RELEASED); }
diff --git a/cpp/src/endpoint.cpp b/cpp/src/endpoint.cpp
index b99ab46..56ef238 100644
--- a/cpp/src/endpoint.cpp
+++ b/cpp/src/endpoint.cpp
@@ -66,6 +66,6 @@ void link::close(const error_condition& condition) {
     close();
 }
 
-endpoint::~endpoint() {}
+endpoint::~endpoint() = default;
 
 }
diff --git a/cpp/src/error.cpp b/cpp/src/error.cpp
index 62655bb..8f6dacd 100644
--- a/cpp/src/error.cpp
+++ b/cpp/src/error.cpp
@@ -22,12 +22,12 @@
 namespace proton {
 
 error::error(const std::string& msg) : std::runtime_error(msg) {}
-error::~error() throw() {}
+error::~error() throw() = default;
 
 timeout_error::timeout_error(const std::string& msg) : error(msg) {}
-timeout_error::~timeout_error() throw() {}
+timeout_error::~timeout_error() throw() = default;
 
 conversion_error::conversion_error(const std::string& msg) : error(msg) {}
-conversion_error::~conversion_error() throw() {}
+conversion_error::~conversion_error() throw() = default;
 
 }
diff --git a/cpp/src/handler.cpp b/cpp/src/handler.cpp
index 589b672..1632efd 100644
--- a/cpp/src/handler.cpp
+++ b/cpp/src/handler.cpp
@@ -37,9 +37,9 @@
 
 namespace proton {
 
-messaging_handler::messaging_handler(){}
+messaging_handler::messaging_handler() = default;
 
-messaging_handler::~messaging_handler(){}
+messaging_handler::~messaging_handler() = default;
 
 void messaging_handler::on_container_start(container &) {}
 void messaging_handler::on_container_stop(container &) {}
diff --git a/cpp/src/listener.cpp b/cpp/src/listener.cpp
index 4676f72..931600a 100644
--- a/cpp/src/listener.cpp
+++ b/cpp/src/listener.cpp
@@ -34,7 +34,7 @@ listener::listener(): listener_(0) {}
 listener::listener(pn_listener_t* l): listener_(l) {}
 // Out-of-line big-3 with trivial implementations, in case we need them in 
future.
 listener::listener(const listener& l) : listener_(l.listener_) {}
-listener::~listener() {}
+listener::~listener() = default;
 listener& listener::operator=(const listener& l) { listener_ = l.listener_; 
return *this; }
 
 void listener::stop() {
@@ -61,7 +61,7 @@ class container& listener::container() const {
 }
 
 // Listen handler
-listen_handler::~listen_handler() {}
+listen_handler::~listen_handler() = default;
 void listen_handler::on_open(listener&) {}
 connection_options listen_handler::on_accept(listener&) { return 
connection_options(); }
 void listen_handler::on_error(listener&, const std::string& what)  { throw 
proton::error(what); }
diff --git a/cpp/src/map.cpp b/cpp/src/map.cpp
index c152d77..fbb60a8 100644
--- a/cpp/src/map.cpp
+++ b/cpp/src/map.cpp
@@ -50,7 +50,7 @@ public:
 };
 
 template <class K, class T>
-map<K,T>::map() {}
+map<K,T>::map() = default;
 
 template <class K, class T>
 map<K,T>::map(const map& x) { *this = x; }
@@ -105,7 +105,7 @@ map<K,T>& map<K,T>::operator=(map&& x) {
 }
 
 template <class K, class T>
-map<K,T>::~map() {}
+map<K,T>::~map() = default;
 
 // Make sure map_ is valid
 template <class K, class T>
diff --git a/cpp/src/node_options.cpp b/cpp/src/node_options.cpp
index 2b506fd..fd489ba 100644
--- a/cpp/src/node_options.cpp
+++ b/cpp/src/node_options.cpp
@@ -127,7 +127,7 @@ source_options::source_options() : impl_(new impl()) {}
 source_options::source_options(const source_options& x) : impl_(new impl()) {
     *this = x;
 }
-source_options::~source_options() {}
+source_options::~source_options() = default;
 
 source_options& source_options::operator=(const source_options& x) {
     *impl_ = *x.impl_;
@@ -182,7 +182,7 @@ target_options::target_options() : impl_(new impl()) {}
 target_options::target_options(const target_options& x) : impl_(new impl()) {
     *this = x;
 }
-target_options::~target_options() {}
+target_options::~target_options() = default;
 
 target_options& target_options::operator=(const target_options& x) {
     *impl_ = *x.impl_;
diff --git a/cpp/src/receiver.cpp b/cpp/src/receiver.cpp
index 4d24c6f..325036d 100644
--- a/cpp/src/receiver.cpp
+++ b/cpp/src/receiver.cpp
@@ -39,7 +39,7 @@ namespace proton {
 
 receiver::receiver(pn_link_t* r): link(make_wrapper(r)) {}
 
-receiver::~receiver() {}
+receiver::~receiver() = default;
 
 void receiver::open() {
     attach();
diff --git a/cpp/src/receiver_options.cpp b/cpp/src/receiver_options.cpp
index 8f315e2..9b7f0e8 100644
--- a/cpp/src/receiver_options.cpp
+++ b/cpp/src/receiver_options.cpp
@@ -116,7 +116,7 @@ receiver_options::receiver_options() : impl_(new impl()) {}
 receiver_options::receiver_options(const receiver_options& x) : impl_(new 
impl()) {
     *this = x;
 }
-receiver_options::~receiver_options() {}
+receiver_options::~receiver_options() = default;
 
 receiver_options& receiver_options::operator=(const receiver_options& x) {
     *impl_ = *x.impl_;
diff --git a/cpp/src/reconnect_options.cpp b/cpp/src/reconnect_options.cpp
index 890cf36..74dc3cf 100644
--- a/cpp/src/reconnect_options.cpp
+++ b/cpp/src/reconnect_options.cpp
@@ -28,7 +28,7 @@ reconnect_options::reconnect_options() : impl_(new impl()) {}
 reconnect_options::reconnect_options(const reconnect_options& x) : impl_(new 
impl) {
     *this = x;
 }
-reconnect_options::~reconnect_options() {}
+reconnect_options::~reconnect_options() = default;
 
 reconnect_options& reconnect_options::operator=(const reconnect_options& x) {
     *impl_ = *x.impl_;
diff --git a/cpp/src/sender.cpp b/cpp/src/sender.cpp
index 6aaeed1..1fbb5ce 100644
--- a/cpp/src/sender.cpp
+++ b/cpp/src/sender.cpp
@@ -40,7 +40,7 @@ namespace proton {
 
 sender::sender(pn_link_t *l): link(make_wrapper(l)) {}
 
-sender::~sender() {}
+sender::~sender() = default;
 
 void sender::open() {
     attach();
diff --git a/cpp/src/sender_options.cpp b/cpp/src/sender_options.cpp
index fc6b39e..53b48fe 100644
--- a/cpp/src/sender_options.cpp
+++ b/cpp/src/sender_options.cpp
@@ -104,7 +104,7 @@ sender_options::sender_options() : impl_(new impl()) {}
 sender_options::sender_options(const sender_options& x) : impl_(new impl()) {
     *this = x;
 }
-sender_options::~sender_options() {}
+sender_options::~sender_options() = default;
 
 sender_options& sender_options::operator=(const sender_options& x) {
     *impl_ = *x.impl_;
diff --git a/cpp/src/session.cpp b/cpp/src/session.cpp
index fb2e6b3..7ba809b 100644
--- a/cpp/src/session.cpp
+++ b/cpp/src/session.cpp
@@ -36,7 +36,7 @@
 
 namespace proton {
 
-session::~session() {}
+session::~session() = default;
 
 void session::open() {
     pn_session_open(pn_object());
diff --git a/cpp/src/session_options.cpp b/cpp/src/session_options.cpp
index fc03ebb..8cfeea8 100644
--- a/cpp/src/session_options.cpp
+++ b/cpp/src/session_options.cpp
@@ -57,7 +57,7 @@ session_options::session_options() : impl_(new impl()) {}
 session_options::session_options(const session_options& x) : impl_(new impl()) 
{
     *this = x;
 }
-session_options::~session_options() {}
+session_options::~session_options() = default;
 
 session_options& session_options::operator=(const session_options& x) {
     *impl_ = *x.impl_;
diff --git a/cpp/src/url.cpp b/cpp/src/url.cpp
index 051954e..239bbe7 100644
--- a/cpp/src/url.cpp
+++ b/cpp/src/url.cpp
@@ -220,7 +220,7 @@ const char* const url::impl::default_host = "localhost";
 
 
 url_error::url_error(const std::string& s) : error(s) {}
-url_error::~url_error() throw() {}
+url_error::~url_error() throw() = default;
 
 url::url(const std::string &s) : impl_(new impl(s)) { impl_->defaults(); }
 
diff --git a/cpp/src/value.cpp b/cpp/src/value.cpp
index 7a30cd3..184e230 100644
--- a/cpp/src/value.cpp
+++ b/cpp/src/value.cpp
@@ -33,7 +33,7 @@ using codec::decoder;
 using codec::encoder;
 using codec::start;
 
-value::value() {}
+value::value() = default;
 value::value(pn_data_t *d) { data_ = make_wrapper(d); }
 value::value(const value& x) { *this = x; }
 value::value(value&& x) { swap(*this, x); }
diff --git a/cpp/src/work_queue.cpp b/cpp/src/work_queue.cpp
index 4c29b2f..6e27f56 100644
--- a/cpp/src/work_queue.cpp
+++ b/cpp/src/work_queue.cpp
@@ -30,10 +30,10 @@
 
 namespace proton {
 
-work_queue::work_queue() {}
+work_queue::work_queue() = default;
 work_queue::work_queue(container& c) { *this = 
container::impl::make_work_queue(c); }
 
-work_queue::~work_queue() {}
+work_queue::~work_queue() = default;
 
 work_queue& work_queue::operator=(impl* i) { impl_.reset(i); return *this; }
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to