I have class where I use boost asio library:
Header:
class TestIOService {
public:
void makeConnection();
static TestIOService getInst();
private:
TestIOService(std::string address);
std::string address;
// boost::asio::io_service service;
};
Impl:
#include <boost/asio/ip/address.hpp>
#include <boost/asio/ip/udp.hpp>
#include "TestIOService.h"
void TestIOService::makeConnection() {
boost::asio::io_service service;
boost::asio::ip::udp::socket socket(service);
boost::asio::ip::udp::endpoint endpoint(boost::asio::ip::address::from_string("192.168.1.2"), 1234);
socket.connect(endpoint);
socket.close();
}
TestIOService::TestIOService(std::string address) : address(address) { }
TestIOService TestIOService::getInst() {
return TestIOService("192.168.1.2");
}
And main:
int main(void)
{
TestIOService service = TestIOService::getInst();
service.makeConnection();
}
When I have service defined in makeConnection method with this line:
boost::asio::io_service service;
there is no problem, but when I have it as class field member(commented out in code) I get this error:
note: ‘TestIOService::TestIOService(TestIOService&&)’ is implicitly deleted because the default definition would be ill-formed: class TestIOService {