Skip to content

Commit ce50e7e

Browse files
committed
Fix the build with C++20 and C++23
C++20 deprecates the implicit capture of this by [=], and GCC warns about it, so capture this explicitly in slog's async_log_service, and use a local pointer in the mDNS service advertiser, as the service discovery implementation already does. C++23 treats a returned local variable as an rvalue, which cannot bind to the non-const copy constructor of Catch's OptBuilder, so take a const reference instead. Signed-off-by: Gareth Sylvester-Bradley <garethsb@nvidia.com>
1 parent 9dabe3e commit ce50e7e

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

‎Development/mdns/service_advertiser_impl.cpp‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,33 +297,36 @@ namespace mdns
297297

298298
pplx::task<bool> register_address(const std::string& host_name, const std::string& ip_address, const std::string& domain, std::uint32_t interface_id) override
299299
{
300+
auto impl = this;
300301
return pplx::create_task([=]
301302
{
302303
// "Note: client is responsible for serializing access to these structures if
303304
// they are shared between concurrent threads."
304305
// See dns_sd.h
305-
std::lock_guard<std::mutex> lock(mutex);
306-
return mdns_details::register_address(client, host_name, ip_address, domain, interface_id, gate);
306+
std::lock_guard<std::mutex> lock(impl->mutex);
307+
return mdns_details::register_address(impl->client, host_name, ip_address, domain, interface_id, impl->gate);
307308
});
308309
}
309310

310311
pplx::task<bool> register_service(const std::string& name, const std::string& type, std::uint16_t port, const std::string& domain, const std::string& host_name, const txt_records& txt_records) override
311312
{
313+
auto impl = this;
312314
return pplx::create_task([=]
313315
{
314316
// Lock also required here, for services
315-
std::lock_guard<std::mutex> lock(mutex);
316-
return mdns_details::register_service(services, name, type, port, domain, host_name, txt_records, gate);
317+
std::lock_guard<std::mutex> lock(impl->mutex);
318+
return mdns_details::register_service(impl->services, name, type, port, domain, host_name, txt_records, impl->gate);
317319
});
318320
}
319321

320322
pplx::task<bool> update_record(const std::string& name, const std::string& type, const std::string& domain, const txt_records& txt_records) override
321323
{
324+
auto impl = this;
322325
return pplx::create_task([=]
323326
{
324327
// Lock also required here, for services
325-
std::lock_guard<std::mutex> lock(mutex);
326-
return mdns_details::update_record(services, name, type, domain, txt_records, gate);
328+
std::lock_guard<std::mutex> lock(impl->mutex);
329+
return mdns_details::update_record(impl->services, name, type, domain, txt_records, impl->gate);
327330
});
328331
}
329332

‎Development/slog/all_in_one.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3888,13 +3888,13 @@ namespace slog
38883888

38893889
explicit async_log_service(service_function service_fun = service_function())
38903890
: discarded(0)
3891-
, worker([=](){ service.run(service_fun); })
3891+
, worker([this, service_fun](){ service.run(service_fun); })
38923892
{}
38933893

38943894
explicit async_log_service(size_type capacity, service_function service_fun = service_function())
38953895
: service(capacity)
38963896
, discarded(0)
3897-
, worker([=](){ service.run(service_fun); })
3897+
, worker([this, service_fun](){ service.run(service_fun); })
38983898
{}
38993899

39003900
~async_log_service()

‎Development/third_party/catch/catch.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4794,7 +4794,7 @@ namespace Clara {
47944794
class OptBuilder : public ArgBuilder {
47954795
public:
47964796
OptBuilder( Arg* arg ) : ArgBuilder( arg ) {}
4797-
OptBuilder( OptBuilder& other ) : ArgBuilder( other ) {}
4797+
OptBuilder( OptBuilder const& other ) : ArgBuilder( other ) {}
47984798
47994799
OptBuilder& operator[]( std::string const& optName ) {
48004800
addOptName( *ArgBuilder::m_arg, optName );

0 commit comments

Comments
 (0)