Skip to content
This repository was archived by the owner on Jun 12, 2018. It is now read-only.

Commit c477ab9

Browse files
committed
warnings: remove unused captures in lambdas
Found with clang's -Wunused-lambda-capture
1 parent 6192c13 commit c477ab9

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

http_examples.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ int main() {
8989

9090
//GET-example for the path /match/[number], responds with the matched string in path (number)
9191
//For instance a request GET /match/123 will receive: 123
92-
server.resource["^/match/([0-9]+)$"]["GET"]=[&server](shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request) {
92+
server.resource["^/match/([0-9]+)$"]["GET"]=[](shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request) {
9393
string number=request->path_match[1];
9494
*response << "HTTP/1.1 200 OK\r\nContent-Length: " << number.length() << "\r\n\r\n" << number;
9595
};
9696

9797
//Get example simulating heavy work in a separate thread
98-
server.resource["^/work$"]["GET"]=[&server](shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> /*request*/) {
98+
server.resource["^/work$"]["GET"]=[](shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> /*request*/) {
9999
thread work_thread([response] {
100100
this_thread::sleep_for(chrono::seconds(5));
101101
string message="Work done";

https_examples.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ int main() {
8787

8888
//GET-example for the path /match/[number], responds with the matched string in path (number)
8989
//For instance a request GET /match/123 will receive: 123
90-
server.resource["^/match/([0-9]+)$"]["GET"]=[&server](shared_ptr<HttpsServer::Response> response, shared_ptr<HttpsServer::Request> request) {
90+
server.resource["^/match/([0-9]+)$"]["GET"]=[](shared_ptr<HttpsServer::Response> response, shared_ptr<HttpsServer::Request> request) {
9191
string number=request->path_match[1];
9292
*response << "HTTP/1.1 200 OK\r\nContent-Length: " << number.length() << "\r\n\r\n" << number;
9393
};
9494

9595
//Get example simulating heavy work in a separate thread
96-
server.resource["^/work$"]["GET"]=[&server](shared_ptr<HttpsServer::Response> response, shared_ptr<HttpsServer::Request> /*request*/) {
96+
server.resource["^/work$"]["GET"]=[](shared_ptr<HttpsServer::Response> response, shared_ptr<HttpsServer::Request> /*request*/) {
9797
thread work_thread([response] {
9898
this_thread::sleep_for(chrono::seconds(5));
9999
string message="Work done";

server_http.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ namespace SimpleWeb {
217217

218218
///Use this function if you need to recursively send parts of a longer message
219219
void send(const std::shared_ptr<Response> &response, const std::function<void(const boost::system::error_code&)>& callback=nullptr) const {
220-
boost::asio::async_write(*response->socket, response->streambuf, [this, response, callback](const boost::system::error_code& ec, size_t /*bytes_transferred*/) {
220+
boost::asio::async_write(*response->socket, response->streambuf, [response, callback](const boost::system::error_code& ec, size_t /*bytes_transferred*/) {
221+
(void) response; // response is not used here, but needs to captured to keep it alive because async_write is using response->*-fields
221222
if(callback)
222223
callback(ec);
223224
});

tests/io_test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ int main() {
2828
*response << "HTTP/1.1 200 OK\r\nContent-Length: " << content_stream.tellp() << "\r\n\r\n" << content_stream.rdbuf();
2929
};
3030

31-
server.resource["^/match/([0-9]+)$"]["GET"]=[&server](shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request) {
31+
32+
server.resource["^/match/([0-9]+)$"]["GET"]=[](shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request) {
3233
string number=request->path_match[1];
3334
*response << "HTTP/1.1 200 OK\r\nContent-Length: " << number.length() << "\r\n\r\n" << number;
3435
};

0 commit comments

Comments
 (0)