Reputation: 746
my question is how do I assign the smart pointer to the other ? I am not sure how to get around the temporary variable either ?
typedef boost::asio::ip::tcp::socket TBoostSocket;
typedef boost::shared_ptr<TBoostSocket> TSocket;
TSocket createSocket(const IpcNode::TPath& a_path) {
TSocket socket(new TBoostSocket(*this->getIoservice()));
return socket;
}
//in another function
TSocket result();
result= createSocket(a_path);
// compiler output
error: taking address of temporary [-fpermissive]
41: error: assignment of function ‘IPC::TcpServices::TSocket IPC::result() cannot convert ‘TSocket* {aka boost::shared_ptr >*}’ to ‘TSocket() {aka boost::shared_ptr >()}’ in assignment
I know I am missing something obvious I just can see it right now
Upvotes: 0
Views: 222
Reputation: 500883
The following declares a function (that takes no arguments and returns TSocket
):
TSocket result();
Change it to:
TSocket result;
Upvotes: 2