Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions generator/internal/scaffold_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -983,8 +983,8 @@ int main(int argc, char* argv[]) try {
auto client = $library$::ServiceClient(
$library$::MakeServiceConnection()); // EDIT HERE

for (auto r : client.List/*EDIT HERE*/(location.FullName())) {
if (!r) throw std::move(r).status();
for (auto const& r : client.List/*EDIT HERE*/(location.FullName())) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Changing r to auto const& means that std::move(r) on the next line (line 987) is now redundant and misleading, as you cannot move from a const reference. It will silently fall back to a copy. Consider removing std::move and calling r.status() directly.

if (!r) throw r.status();
std::cout << r->DebugString() << "\n";
}

Expand Down
1 change: 1 addition & 0 deletions generator/internal/scaffold_generator_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ TEST_F(ScaffoldGenerator, QuickstartSkeleton) {
auto const actual = std::move(os).str();
EXPECT_THAT(actual, HasSubstr("2034"));
EXPECT_THAT(actual, Not(HasSubstr("$copyright_year$")));
EXPECT_THAT(actual, HasSubstr("for (auto const& r : client.List"));
}

TEST_F(ScaffoldGenerator, QuickstartCMake) {
Expand Down
Loading