Fix new gcc 9 'deprecated-copy' warning.
Example warning: cppdap/include/dap/future.h:172:14: error: implicitly-declared ‘dap::ResponseOrError<dap::StackTraceResponse>& dap::ResponseOrError<dap::StackTraceResponse>::operator=(const dap::ResponseOrError<dap::StackTraceResponse>&)’ is deprecated [-Werror=deprecated-copy] Add missing constructors and assignment operators. This probably adds more than is absolutely necessary, but there's no harm in being thorough.
This commit is contained in:
parent
de7dffaf66
commit
c4358807e2
@ -84,8 +84,14 @@ struct ResponseOrError {
|
||||
|
||||
inline ResponseOrError() = default;
|
||||
inline ResponseOrError(const T& response);
|
||||
inline ResponseOrError(T&& response);
|
||||
inline ResponseOrError(const Error& error);
|
||||
inline ResponseOrError(Error&& error);
|
||||
inline ResponseOrError(const ResponseOrError& other);
|
||||
inline ResponseOrError(ResponseOrError&& other);
|
||||
|
||||
inline ResponseOrError& operator=(const ResponseOrError& other);
|
||||
inline ResponseOrError& operator=(ResponseOrError&& other);
|
||||
|
||||
T response;
|
||||
Error error; // empty represents success.
|
||||
@ -94,10 +100,31 @@ struct ResponseOrError {
|
||||
template <typename T>
|
||||
ResponseOrError<T>::ResponseOrError(const T& response) : response(response) {}
|
||||
template <typename T>
|
||||
ResponseOrError<T>::ResponseOrError(T&& response)
|
||||
: response(std::move(response)) {}
|
||||
template <typename T>
|
||||
ResponseOrError<T>::ResponseOrError(const Error& error) : error(error) {}
|
||||
template <typename T>
|
||||
ResponseOrError<T>::ResponseOrError(Error&& error) : error(std::move(error)) {}
|
||||
template <typename T>
|
||||
ResponseOrError<T>::ResponseOrError(const ResponseOrError& other)
|
||||
: response(other.response), error(other.error) {}
|
||||
template <typename T>
|
||||
ResponseOrError<T>::ResponseOrError(ResponseOrError&& other)
|
||||
: response(std::move(other.response)), error(std::move(other.error)) {}
|
||||
template <typename T>
|
||||
ResponseOrError<T>& ResponseOrError<T>::operator=(
|
||||
const ResponseOrError& other) {
|
||||
response = other.response;
|
||||
error = other.error;
|
||||
return *this;
|
||||
}
|
||||
template <typename T>
|
||||
ResponseOrError<T>& ResponseOrError<T>::operator=(ResponseOrError&& other) {
|
||||
response = std::move(other.response);
|
||||
error = std::move(other.error);
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Session
|
||||
@ -252,8 +279,7 @@ template <typename T, typename>
|
||||
future<ResponseOrError<typename T::Response>> Session::send(const T& request) {
|
||||
using Response = typename T::Response;
|
||||
promise<ResponseOrError<Response>> promise;
|
||||
auto sent = send(
|
||||
TypeOf<T>::type(), TypeOf<Response>::type(), &request,
|
||||
auto sent = send(TypeOf<T>::type(), TypeOf<Response>::type(), &request,
|
||||
[=](const void* result, const Error* error) {
|
||||
if (error != nullptr) {
|
||||
promise.set_value(ResponseOrError<Response>(*error));
|
||||
|
Loading…
x
Reference in New Issue
Block a user