Skip to content

Commit

Permalink
absl::StrJoin does not know about ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
eggrobin committed Mar 30, 2024
1 parent 958494e commit a7a7ffa
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions base/cpuid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <ranges>
#include <vector>

#include "absl/strings/str_join.h"
#include "base/macros.hpp" // 🧙 For PRINCIPIA_COMPILER_MSVC.
#include "glog/logging.h"

Expand Down Expand Up @@ -86,11 +87,21 @@ std::string ProcessorBrandString() {
}

std::string CPUFeatures() {
#if PRINCIPIA_COMPILER_MSVC
return CPUIDFlags()
| std::views::filter(&CPUIDFeatureFlag::IsSet)
| std::views::transform(&CPUIDFeatureFlag::name)

Check warning on line 93 in base/cpuid.cpp

View workflow job for this annotation

GitHub Actions / check-cpp

build/include_what_you_use

Add #include <algorithm> for transform
| std::views::join_with(' ')
| std::ranges::to<std::string>();
#else // TODO(egg): Get rid of this once clang really has C++23.
std::vector<std::string_view> set_flags;
for (auto const& flag : CPUIDFlags()) {
if (flag.IsSet()) {
set_flags.push_back(flag.name());
}
}
return absl::StrJoin(set_flags, " ");
#endif
}

} // namespace internal
Expand Down

0 comments on commit a7a7ffa

Please sign in to comment.