title: Getting C2280 (attempting to reference a deleted function) when using future
body: <p>I am using the poco libraries, and I'm trying to wrap them into a nicer HTTPClient that I can use everywhere in a few lines, and also make them async. To that end, I am using std::future and a custom response struct. However, for some reason, it tells me it's trying to reference a deleted function. I'm not deleting anything, so I don't really know why it would be saying this.</p>
  
  <p>httpclient.h</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;Poco/Net/HTTPSClientSession.h&gt;
  #include &lt;Poco/Net/HTTPRequest.h&gt;
  #include &lt;Poco/Net/HTTPResponse.h&gt;
  #include &lt;Poco/Exception.h&gt;
  #include &lt;Poco/URI.h&gt;
  #include &lt;future&gt;
  #include &lt;map&gt;
  
  typedef struct response {
      std::istream&amp; is;
      Poco::Net::HTTPResponse&amp; response;
  } RES;
  
  class HttpClient {
  public:
      static std::future&lt;RES&gt; get(Poco::Net::HTTPSClientSession&amp; session, Poco::URI url, std::map&lt;std::string, std::string&gt; headers = {});
  };
  </code></pre>
  
  <p>httpclient.cpp</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include "httpclient.h"
  
  std::future&lt;RES&gt; HttpClient::get(Poco::Net::HTTPSClientSession&amp; session, Poco::URI url, std::map&lt;std::string, std::string&gt; headers) {
      return std::async(std::launch::async, [&amp;session, url, headers](){
          try {
              std::string path(url.getPathAndQuery());
              if (path.empty()) path = "/";
  
              Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, path, Poco::Net::HTTPMessage::HTTP_1_1);
              request.add("Content-Length", "0");
  
              if (headers.size() &gt; 0) {
                  for (std::map&lt;std::string, std::string&gt;::const_iterator itr = headers.begin(); itr != headers.end(); ++itr) {
                      request.add(itr-&gt;first, itr-&gt;second);
                  }
              }
  
              Poco::Net::HTTPResponse _res;
              session.sendRequest(request);
              std::istream&amp; is = session.receiveResponse(_res);
              return RES { is, _res };
          }
          catch (Poco::Exception &amp; exc) {
              OutputDebugStringA(exc.displayText().c_str());
          }
      });
  }
  </code></pre>
  
  <p>main.cpp</p>
  
  <pre class="lang-cpp prettyprint-override"><code>Poco::Net::initializeSSL();
  
      Poco::URI uri("https://www.google.com");
      const Poco::Net::Context::Ptr context = new Poco::Net::Context(Poco::Net::Context::CLIENT_USE, "", "", "", Poco::Net::Context::VERIFY_NONE, 9, false, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
      Poco::Net::HTTPSClientSession session(uri.getHost(), uri.getPort(), context);
  
      std::future&lt;RES&gt; response = HttpClient::get(session, uri, {});
      response.get();
  </code></pre>
  
  <p>This is the precise error I got:
  <code>C2280: response &amp;response::operator =(const response &amp;)': attempting to reference a deleted function     future:line 332</code>.</p>
  
  <p>Thank you!</p>