From a7a7ffa8b0fec122b54245e0e683ecf57733c458 Mon Sep 17 00:00:00 2001 From: Robin Leroy Date: Sat, 30 Mar 2024 23:24:41 +0100 Subject: [PATCH] absl::StrJoin does not know about ranges --- base/cpuid.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/base/cpuid.cpp b/base/cpuid.cpp index f658e8784f..268f292f7e 100644 --- a/base/cpuid.cpp +++ b/base/cpuid.cpp @@ -4,6 +4,7 @@ #include #include +#include "absl/strings/str_join.h" #include "base/macros.hpp" // 🧙 For PRINCIPIA_COMPILER_MSVC. #include "glog/logging.h" @@ -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) | std::views::join_with(' ') | std::ranges::to(); +#else // TODO(egg): Get rid of this once clang really has C++23. + std::vector set_flags; + for (auto const& flag : CPUIDFlags()) { + if (flag.IsSet()) { + set_flags.push_back(flag.name()); + } + } + return absl::StrJoin(set_flags, " "); +#endif } } // namespace internal