Skip to content

VS2015: Deleted copy assignment in response class? #547

@rcdailey

Description

@rcdailey

I'm finding something very strange. I get the following compiler error when building with Visual Studio 2015:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\future(380): error C2280: 'network::http::v2::client_message::response &network::http::v2::client_message::response::operator =(const network::http::v2::client_message::response &)': attempting to reference a deleted function
  C:\code\obs-twitch-integration\cpp-netlib\http\src\network/http/v2/client/response.hpp(199): note: compiler has generated 'network::http::v2::client_message::response::operator =' here
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\future(376): note: while compiling class template member function 'void std::_Associated_state<_Ty>::_Set_value_raw(const _Ty &,std::unique_lock<std::mutex> *,bool)'
          with
          [
              _Ty=network::http::v2::response
          ]
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\future(371): note: see reference to function template instantiation 'void std::_Associated_state<_Ty>::_Set_value_raw(const _Ty &,std::unique_lock<std::mutex> *,bool)' being compiled
          with
          [
              _Ty=network::http::v2::response
          ]
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\future(1491): note: see reference to class template instantiation 'std::_Associated_state<_Ty>' being compiled
          with
          [
              _Ty=network::http::v2::response
          ]
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\future(1491): note: while compiling class template member function 'std::promise<network::http::v2::response>::promise(void)'
  C:\code\obs-twitch-integration\cpp-netlib\http\src\http\v2\client\client.cpp(46): note: see reference to function template instantiation 'std::promise<network::http::v2::response>::promise(void)' being compiled
  C:\code\obs-twitch-integration\cpp-netlib\http\src\http\v2\client\client.cpp(32): note: see reference to class template instantiation 'std::promise<network::http::v2::response>' being compiled

The only thing regarding copy/move/construction explicitly declared in the code is below:

  /**
   * \brief Constructor.
   */
  response() = default;

  /**
   * \brief Copy constructor.
   * \param other The other response object.
   */
  response(const response &other) = default;

  /**
   * \brief Move constructor.
   * \param other The other response object.
   */
  response(response &&other) noexcept = default;

Oddly enough, when I delete these (and let them be implicitly declared by the compiler, which they would be anyway BTW) the code compiles fine. Is this a bug in VS 2015? Note that as of C++11, implicitly declared copy assignment is deprecated when an explicitly declared copy constructor is present. But that is deprecation. So legally a copy assignment should still be implicitly declared in this class AFAIK.

Any idea what the issue is? I thought about submitting a PR with the removal of these but I figured a little RCA is justified.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions