| 1 | From: Johannes Müller <[email protected]>
|
| 2 | Date: Thu, 29 Aug 2025 08:06:40 +0200
|
| 3 | Subject: Bind string as string_view via temporary variable
|
| 4 |
|
| 5 | Cast string to string_view using a temporary variable to allow pass-by-reference to prevent error: cannot bind non-const lvalue reference of type 'std::basic_string_view&' to an rvalue of type 'std::__cxx11::basic_string::__sv_type' {aka 'std::basic_string_view'}
|
| 6 |
|
| 7 | |
| 8 | |
| 9 | @@ -331,21 +331,25 @@
|
| 10 | return std::nullopt;
|
| 11 | }
|
| 12 | if (key == "main") {
|
| 13 | - if (field.value().get_string().get(result.main_path) ||
|
| 14 | - result.main_path.empty()) {
|
| 15 | + std::string_view main_path_view = result.main_path;
|
| 16 | + if (field.value().get_string().get(main_path_view) ||
|
| 17 | + main_path_view.empty()) {
|
| 18 | FPrintF(stderr,
|
| 19 | "\"main\" field of %s is not a non-empty string\n",
|
| 20 | config_path);
|
| 21 | return std::nullopt;
|
| 22 | }
|
| 23 | + result.main_path = main_path_view;
|
| 24 | } else if (key == "output") {
|
| 25 | - if (field.value().get_string().get(result.output_path) ||
|
| 26 | - result.output_path.empty()) {
|
| 27 | + std::string_view output_path_view = result.output_path;
|
| 28 | + if (field.value().get_string().get(output_path_view) ||
|
| 29 | + output_path_view.empty()) {
|
| 30 | FPrintF(stderr,
|
| 31 | "\"output\" field of %s is not a non-empty string\n",
|
| 32 | config_path);
|
| 33 | return std::nullopt;
|
| 34 | }
|
| 35 | + result.output_path = output_path_view;
|
| 36 | } else if (key == "disableExperimentalSEAWarning") {
|
| 37 | bool disable_experimental_sea_warning;
|
| 38 | if (field.value().get_bool().get(disable_experimental_sea_warning)) {
|