Skip to content

Commit 93c498a

Browse files
committed
Explicit capture for num_events for MSVC.
1 parent a80d0a5 commit 93c498a

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

examples/hello-cpp-client/main.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,25 @@ int main() {
5353
}
5454
} else {
5555
std::cout << "*** SDK initialization didn't complete in "
56-
<< INIT_TIMEOUT_MILLISECONDS << "ms\n";
56+
<< INIT_TIMEOUT_MILLISECONDS << "ms\n";
5757
return 1;
5858
}
5959

6060
bool const flag_value = client.BoolVariation(FEATURE_FLAG_KEY, false);
6161

6262
std::cout << "*** Feature flag '" << FEATURE_FLAG_KEY << "' is "
63-
<< (flag_value ? "true" : "false") << " for this user\n\n";
63+
<< (flag_value ? "true" : "false") << " for this user\n\n";
64+
65+
client.FlagNotifier().OnFlagChange("my-boolean-flag",
66+
[](const std::shared_ptr<
67+
flag_manager::FlagValueChangeEvent>
68+
& change_event) {
69+
std::cout << "my-boolean-flag changed! " << change_event->NewValue() << std::endl;
70+
});
71+
72+
// Keep it running.
73+
std::string in;
74+
std::cin >> in;
6475

6576
return 0;
6677
}
@@ -79,4 +90,4 @@ char const* get_with_env_fallback(char const* source_val,
7990

8091
std::cout << "*** " << error_msg << std::endl;
8192
std::exit(1);
82-
}
93+
}

libs/server-sent-events/tests/curl_client_test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,8 @@ TEST(CurlClientTest, HandlesRapidEvents) {
759759
MockSSEServer server;
760760
constexpr int num_events = 100;
761761

762-
auto port = server.start([](auto const&, auto send_response, auto send_sse_event, auto close) {
762+
// num_events needs to be captured for MSVC.
763+
auto port = server.start([num_events](auto const&, auto send_response, auto send_sse_event, auto close) {
763764
http::response<http::string_body> res{http::status::ok, 11};
764765
res.set(http::field::content_type, "text/event-stream");
765766
res.chunked(true);

0 commit comments

Comments
 (0)