chore(bigquery): migrate to std::optional by colinmoy · Pull Request #16210 · googleapis/google-cloud-cpp · GitHub
Skip to content

chore(bigquery): migrate to std::optional#16210

Open
colinmoy wants to merge 1 commit into
googleapis:mainfrom
colinmoy:migrate-bigquery-optional
Open

chore(bigquery): migrate to std::optional#16210
colinmoy wants to merge 1 commit into
googleapis:mainfrom
colinmoy:migrate-bigquery-optional

Conversation

@colinmoy

Copy link
Copy Markdown

Replacing explicit usages of absl::optional with std::optional in the BigQuery Client library as part of broader modernization efforts

@colinmoy colinmoy requested a review from a team as a code owner June 26, 2026 21:58
@product-auto-label product-auto-label Bot added the api: bigquery Issues related to the BigQuery API. label Jun 26, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request replaces the use of absl::optional with std::optional across several files in the BigQuery v2 minimal internal library, aligning with C++17 standards. The reviewer suggests returning std::optional<std::chrono::system_clock::time_point> by value instead of by const& in ListJobsRequest because it is a small, trivially copyable type, which avoids pointer indirection and potential lifetime issues.

Comment on lines +117 to 124

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

Since std::chrono::system_clock::time_point is a small, trivially copyable type, std::optional<std::chrono::system_clock::time_point> is also small and cheap to copy. Returning it by value instead of by const& is more idiomatic in C++, avoids pointer indirection overhead, and prevents potential lifetime issues (dangling references) for callers.

  std::optional<std::chrono::system_clock::time_point>
  min_creation_time() const {
    return min_creation_time_;
  }
  std::optional<std::chrono::system_clock::time_point>
  max_creation_time() const {
    return max_creation_time_;
  }

@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigquery Issues related to the BigQuery API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant