From 75025326ec13a76cb2a724380bf7569aa6dc6ecf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be> Date: Sun, 12 Jun 2011 21:41:19 +0200 Subject: Replace explicit new with make_shared. diff --git a/Swiften/Elements/IQ.cpp b/Swiften/Elements/IQ.cpp index 0f452ef..8e6d7cc 100644 --- a/Swiften/Elements/IQ.cpp +++ b/Swiften/Elements/IQ.cpp @@ -24,7 +24,7 @@ boost::shared_ptr<IQ> IQ::createRequest( } boost::shared_ptr<IQ> IQ::createResult(const JID& to, const std::string& id, boost::shared_ptr<Payload> payload) { - boost::shared_ptr<IQ> iq(new IQ(Result)); + boost::shared_ptr<IQ> iq = boost::make_shared<IQ>(Result); iq->setTo(to); iq->setID(id); if (payload) { @@ -34,7 +34,7 @@ boost::shared_ptr<IQ> IQ::createResult(const JID& to, const std::string& id, boo } boost::shared_ptr<IQ> IQ::createResult(const JID& to, const JID& from, const std::string& id, boost::shared_ptr<Payload> payload) { - boost::shared_ptr<IQ> iq(new IQ(Result)); + boost::shared_ptr<IQ> iq = boost::make_shared<IQ>(Result); iq->setTo(to); iq->setFrom(from); iq->setID(id); @@ -45,19 +45,19 @@ boost::shared_ptr<IQ> IQ::createResult(const JID& to, const JID& from, const std } boost::shared_ptr<IQ> IQ::createError(const JID& to, const std::string& id, ErrorPayload::Condition condition, ErrorPayload::Type type) { - boost::shared_ptr<IQ> iq(new IQ(IQ::Error)); + boost::shared_ptr<IQ> iq = boost::make_shared<IQ>(IQ::Error); iq->setTo(to); iq->setID(id); - iq->addPayload(boost::shared_ptr<Swift::ErrorPayload>(new Swift::ErrorPayload(condition, type))); + iq->addPayload(boost::make_shared<Swift::ErrorPayload>(condition, type)); return iq; } boost::shared_ptr<IQ> IQ::createError(const JID& to, const JID& from, const std::string& id, ErrorPayload::Condition condition, ErrorPayload::Type type) { - boost::shared_ptr<IQ> iq(new IQ(IQ::Error)); + boost::shared_ptr<IQ> iq = boost::make_shared<IQ>(IQ::Error); iq->setTo(to); iq->setFrom(from); iq->setID(id); - iq->addPayload(boost::shared_ptr<Swift::ErrorPayload>(new Swift::ErrorPayload(condition, type))); + iq->addPayload(boost::make_shared<Swift::ErrorPayload>(condition, type)); return iq; } diff --git a/Swiften/Elements/Message.h b/Swiften/Elements/Message.h index dc2eaf1..19e3fbb 100644 --- a/Swiften/Elements/Message.h +++ b/Swiften/Elements/Message.h @@ -8,6 +8,7 @@ #include <boost/optional.hpp> #include <boost/shared_ptr.hpp> +#include <boost/smart_ptr/make_shared.hpp> #include <string> #include <Swiften/Elements/Body.h> @@ -34,7 +35,7 @@ namespace Swift { } void setSubject(const std::string& subject) { - updatePayload(boost::shared_ptr<Subject>(new Subject(subject))); + updatePayload(boost::make_shared<Subject>(subject)); } std::string getBody() const { @@ -46,7 +47,7 @@ namespace Swift { } void setBody(const std::string& body) { - updatePayload(boost::shared_ptr<Body>(new Body(body))); + updatePayload(boost::make_shared<Body>(body)); } bool isError() { diff --git a/Swiften/Elements/Presence.cpp b/Swiften/Elements/Presence.cpp index 6cde567..38b8a4c 100644 --- a/Swiften/Elements/Presence.cpp +++ b/Swiften/Elements/Presence.cpp @@ -27,7 +27,7 @@ int Presence::getPriority() const { } void Presence::setPriority(int priority) { - updatePayload(boost::shared_ptr<Priority>(new Priority(priority))); + updatePayload(boost::make_shared<Priority>(priority)); } std::string Presence::getStatus() const { @@ -39,7 +39,7 @@ std::string Presence::getStatus() const { } void Presence::setStatus(const std::string& status) { - updatePayload(boost::shared_ptr<Status>(new Status(status))); + updatePayload(boost::make_shared<Status>(status)); } diff --git a/Swiften/Elements/Presence.h b/Swiften/Elements/Presence.h index 5ae482b..28a9ee5 100644 --- a/Swiften/Elements/Presence.h +++ b/Swiften/Elements/Presence.h @@ -6,6 +6,8 @@ #pragma once +#include <boost/smart_ptr/make_shared.hpp> + #include <Swiften/Elements/Stanza.h> #include <Swiften/Elements/StatusShow.h> @@ -21,15 +23,15 @@ namespace Swift { virtual ~Presence(); static ref create() { - return ref(new Presence()); + return boost::make_shared<Presence>(); } static ref create(const std::string& status) { - return ref(new Presence(status)); + return boost::make_shared<Presence>(status); } static ref create(Presence::ref presence) { - return ref(new Presence(*presence)); + return boost::make_shared<Presence>(*presence); } Type getType() const { return type_; } @@ -44,7 +46,7 @@ namespace Swift { } void setShow(const StatusShow::Type &show) { - updatePayload(boost::shared_ptr<StatusShow>(new StatusShow(show))); + updatePayload(boost::make_shared<StatusShow>(show)); } std::string getStatus() const; @@ -54,7 +56,7 @@ namespace Swift { void setPriority(int priority); boost::shared_ptr<Presence> clone() const { - return boost::shared_ptr<Presence>(new Presence(*this)); + return boost::make_shared<Presence>(*this); } bool isAvailable() const { -- cgit v0.10.2-6-g49f6