mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Remove wpi::ArrayRef std::initializer_list constructor (#1745)
This can be dangerous as it refers to a temporary, and GCC 9.0 warns about its use. Instead add std::initializer_list overloads to common places it was used in an initializer_list sense.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <functional>
|
||||
#include <initializer_list>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
@@ -99,6 +100,25 @@ class WebSocket : public std::enable_shared_from_this<WebSocket> {
|
||||
ArrayRef<StringRef> protocols = ArrayRef<StringRef>{},
|
||||
const ClientOptions& options = ClientOptions{});
|
||||
|
||||
/**
|
||||
* Starts a client connection by performing the initial client handshake.
|
||||
* An open event is emitted when the handshake completes.
|
||||
* This sets the stream user data to the websocket.
|
||||
* @param stream Connection stream
|
||||
* @param uri The Request-URI to send
|
||||
* @param host The host or host:port to send
|
||||
* @param protocols The list of subprotocols
|
||||
* @param options Handshake options
|
||||
*/
|
||||
static std::shared_ptr<WebSocket> CreateClient(
|
||||
uv::Stream& stream, const Twine& uri, const Twine& host,
|
||||
std::initializer_list<StringRef> protocols,
|
||||
const ClientOptions& options = ClientOptions{}) {
|
||||
return CreateClient(stream, uri, host,
|
||||
makeArrayRef(protocols.begin(), protocols.end()),
|
||||
options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a server connection by performing the initial server side handshake.
|
||||
* This should be called after the HTTP headers have been received.
|
||||
|
||||
Reference in New Issue
Block a user