From ff2e64bfee72d671a05f6596b05cfc508b613085 Mon Sep 17 00:00:00 2001 From: Vladislav Nepogodin Date: Sat, 13 Jul 2024 03:23:35 +0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20gucc:=20use=20std=20ranges=20fro?= =?UTF-8?q?m=20C++23=20in=20bootloader?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gucc/src/bootloader.cpp | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/gucc/src/bootloader.cpp b/gucc/src/bootloader.cpp index b16bfc5..ef17a93 100644 --- a/gucc/src/bootloader.cpp +++ b/gucc/src/bootloader.cpp @@ -4,32 +4,13 @@ #include "gucc/io_utils.hpp" #include "gucc/string_utils.hpp" +#include // for ranges::* + #include #include #include -#if defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wold-style-cast" -#elif defined(__GNUC__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wnull-dereference" -#pragma GCC diagnostic ignored "-Wuseless-cast" -#pragma GCC diagnostic ignored "-Wold-style-cast" -#endif - -#include -#include -#include -#include - -#if defined(__clang__) -#pragma clang diagnostic pop -#elif defined(__GNUC__) -#pragma GCC diagnostic pop -#endif - using namespace std::string_view_literals; #define CONV_REQ_F(needle, f) \ @@ -182,14 +163,13 @@ auto parse_grub_line(const gucc::bootloader::GrubConfig& grub_config, std::strin namespace gucc::bootloader { auto gen_grub_config(const GrubConfig& grub_config) noexcept -> std::string { - std::string result = GRUB_DEFAULT_CONFIG | ranges::views::split('\n') - | ranges::views::transform([&](auto&& rng) { - auto&& line = std::string_view(&*rng.begin(), static_cast(ranges::distance(rng))); + std::string result = GRUB_DEFAULT_CONFIG | std::ranges::views::split('\n') + | std::ranges::views::transform([&](auto&& rng) { + auto&& line = std::string_view(&*rng.begin(), static_cast(std::ranges::distance(rng))); return parse_grub_line(grub_config, line); }) - | ranges::views::join('\n') - | ranges::to(); - result += '\n'; + | std::ranges::views::join_with('\n') + | std::ranges::to(); return result; }