Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change copy constructor of endpoint to const & #1020

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

RicardoMDomingues
Copy link

Fix a compilation error when I use the websocketpp::client in a std::variant using libc++. lbstdc++ works fine.

Example of code that does not compile using libc++


#include <websocketpp/config/asio_no_tls_client.hpp>
#include <websocketpp/config/asio_client.hpp>
#include <websocketpp/client.hpp>
#include <variant>

class WebSocketClient
{
    using WsClient = websocketpp::client<websocketpp::config::asio_client>;
    using WssClient = websocketpp::client<websocketpp::config::asio_tls_client>;

    std::variant<WssClient, WsClient> websocketClient;
};

Compilation error:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/usr/include/c++/v1/variant:716:1: error: the parameter for this explicitly-defaulted copy constructor is const, but a member or base requires it to be non-const
_LIBCPP_VARIANT_UNION(_Trait::_Available, ~__union() {});
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/usr/include/c++/v1/variant:699:5: note: expanded from macro '_LIBCPP_VARIANT_UNION'
    __union(const __union&) = default;                                         \
    ^

...
    
                                  ^
In file included from /Users/ricardo.domingues/my-project/src/WebSocketClient.cpp:6:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/usr/include/c++/v1/variant:716:1: error: the parameter for this explicitly-defaulted copy constructor is const, but a member or base requires it to be non-const
_LIBCPP_VARIANT_UNION(_Trait::_Available, ~__union() {});

@Radrik5
Copy link

Radrik5 commented May 24, 2022

websocketpp::client should be wrapped in shared_ptr to avoid crashes in endpoint (fixed in #1041).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants