Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unbreak CI by using C++17 code #264

Merged
merged 1 commit into from
Oct 16, 2024
Merged

Unbreak CI by using C++17 code #264

merged 1 commit into from
Oct 16, 2024

Conversation

ahmadsharif1
Copy link
Contributor

std::string's starts_with method is c++20

So we use a different incantation that's C++17 compliant

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 15, 2024
@@ -168,7 +168,7 @@ void _add_video_stream(
if (device.has_value()) {
if (device.value() == "cpu") {
options.device = torch::Device(torch::kCPU);
} else if (device.value().starts_with("cuda")) {
} else if (device.value().rfind("cuda", 0) == 0) { // starts with "cuda"
Copy link
Contributor

Choose a reason for hiding this comment

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

Since rfind() starts from the end ("reverse find"), this is technically "ends with 'cuda'". See https://en.cppreference.com/w/cpp/string/basic_string/rfind.

Copy link
Contributor Author

@ahmadsharif1 ahmadsharif1 Oct 16, 2024

Choose a reason for hiding this comment

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

rfind with a pos argument of 0 -- rfind(*, 0) -- looks for a prefix

@scotts
Copy link
Contributor

scotts commented Oct 16, 2024

Approving and merging to unbreak CI. We can figure out later if it should be rfind() or find().

@scotts scotts merged commit 41c6491 into pytorch:main Oct 16, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants