diff --git a/src/client.cpp b/src/client.cpp
index 6e42dcaaf01d45b3a3fbc8da266839e476a99340..bb8a7e324953a1e48fcfece994ca93ef11b6f3ec 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -1,5 +1,6 @@
 #include <boost/algorithm/string.hpp>
 #include <boost/bind.hpp>
+#include <boost/utility/typed_in_place_factory.hpp>
 
 #include "client.hpp"
 #include "utils.hpp"
@@ -15,7 +16,8 @@ Client::Client(const std::string &server, uint16_t port)
   , server_{server}
   , port_{port}
 {
-        work_.reset(new boost::asio::io_service::work(ios_));
+        using namespace boost::asio;
+        work_ = boost::in_place<io_service::work>(io_service::work(ios_));
 
         const auto threads_num = std::max(1U, std::thread::hardware_concurrency());
 
@@ -29,7 +31,7 @@ Client::close()
         // Destroy work object. This allows the I/O thread to
         // exit the event loop when there are no more pending
         // asynchronous operations.
-        work_.reset(nullptr);
+        work_ = boost::none;
 
         // Wait for the worker threads to exit.
         thread_group_.join_all();
diff --git a/src/client.hpp b/src/client.hpp
index 84c36f2b1b989a1d51d6ac5ac9ef0a36b23f2cb7..63561eb98beccb270bf76ff1bf7404a2c3c9221a 100644
--- a/src/client.hpp
+++ b/src/client.hpp
@@ -291,7 +291,7 @@ private:
         boost::asio::io_service ios_;
 
         //! Used to prevent the event loop from shutting down.
-        std::unique_ptr<boost::asio::io_service::work> work_;
+        boost::optional<boost::asio::io_service::work> work_;
         //! Worker threads for the requests.
         boost::thread_group thread_group_;
         //! Used to resolve DNS names.