Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions source/common/http/conn_manager_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,19 +231,20 @@ class ConnectionManagerImpl : Logger::Loggable<Logger::Id::http>,

// TODO(snowp): Create shared OptRef/OptConstRef helpers
Http::RequestHeaderMapOptRef requestHeaders() override {
return request_headers_ ? std::make_optional(std::ref(*request_headers_)) : absl::nullopt;
return request_headers_ ? absl::make_optional(std::ref(*request_headers_)) : absl::nullopt;
}
Http::RequestTrailerMapOptRef requestTrailers() override {
return request_trailers_ ? std::make_optional(std::ref(*request_trailers_)) : absl::nullopt;
return request_trailers_ ? absl::make_optional(std::ref(*request_trailers_)) : absl::nullopt;
}
Http::ResponseHeaderMapOptRef continueHeaders() override {
return continue_headers_ ? std::make_optional(std::ref(*continue_headers_)) : absl::nullopt;
return continue_headers_ ? absl::make_optional(std::ref(*continue_headers_)) : absl::nullopt;
}
Http::ResponseHeaderMapOptRef responseHeaders() override {
return response_headers_ ? std::make_optional(std::ref(*response_headers_)) : absl::nullopt;
return response_headers_ ? absl::make_optional(std::ref(*response_headers_)) : absl::nullopt;
}
Http::ResponseTrailerMapOptRef responseTrailers() override {
return response_trailers_ ? std::make_optional(std::ref(*response_trailers_)) : absl::nullopt;
return response_trailers_ ? absl::make_optional(std::ref(*response_trailers_))
: absl::nullopt;
}

void endStream() override {
Expand Down
2 changes: 2 additions & 0 deletions tools/code_format/check_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,8 @@ def checkSourceLine(line, file_path, reportError):
# See: https://github.com/envoyproxy/envoy/issues/12341
if tokenInLine("std::any", line):
reportError("Don't use std::any; use absl::any instead")
if tokenInLine("std::make_optional", line):
reportError("Don't use std::make_optional; use absl::make_optional instead")
if tokenInLine("std::optional", line):
reportError("Don't use std::optional; use absl::optional instead")
if tokenInLine("std::variant", line):
Expand Down
2 changes: 2 additions & 0 deletions tools/code_format/check_format_test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ def runChecks():
"std_unordered_set.cc", "Don't use std::unordered_set; use absl::flat_hash_set instead " +
"or absl::node_hash_set if pointer stability of keys/values is required")
errors += checkUnfixableError("std_any.cc", "Don't use std::any; use absl::any instead")
errors += checkUnfixableError("std_make_optional.cc",
"Don't use std::make_optional; use absl::make_optional instead")
errors += checkUnfixableError("std_optional.cc",
"Don't use std::optional; use absl::optional instead")
errors += checkUnfixableError("std_variant.cc",
Expand Down
8 changes: 8 additions & 0 deletions tools/testdata/check_format/std_make_optional.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <optional>

namespace Envoy {
void foo() {
uint64_t value = 1;
uint64_t optional_value = std::make_optional<uint64_t>(value);
}
} // namespace Envoy