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:
Peter Johnson
2019-06-29 23:54:02 -07:00
committed by GitHub
parent 9e19b29c31
commit 60dce66a4f
17 changed files with 482 additions and 59 deletions

View File

@@ -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.