From d3f511b4583b3771bf941ebc7884477430115039 Mon Sep 17 00:00:00 2001 From: Haowen Liu <35328328+lunacd@users.noreply.github.com> Date: Thu, 1 May 2025 22:06:28 +0100 Subject: [PATCH] subprocess: Fix string_arg when used with rref When passing in a rvalue reference, compiler considers it ambiguous between std::string and std::string&&. Making one of them take a lvalue reference makes compilers correctly pick the right one depending on whether the passed in value binds to a rvalue or lvalue reference. Github-Pull: arun11299/cpp-subprocess#110 Rebased-From: 2d8a8eebb03e509840e2c3c755d1abf32d930f33 --- src/util/subprocess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/subprocess.h b/src/util/subprocess.h index 26651d3ae56..086a4553619 100644 --- a/src/util/subprocess.h +++ b/src/util/subprocess.h @@ -527,7 +527,7 @@ struct string_arg { string_arg(const char* arg): arg_value(arg) {} string_arg(std::string&& arg): arg_value(std::move(arg)) {} - string_arg(std::string arg): arg_value(std::move(arg)) {} + string_arg(const std::string& arg): arg_value(arg) {} std::string arg_value; };