Skip to content

Commit

Permalink
layer: Prefer C++20 ranges::any_of over '11 idioms
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoyvwac authored and misyltoad committed Oct 17, 2023
1 parent c2e198d commit 3401da5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions layer/VkLayer_FROG_gamescope_wsi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <optional>

Expand Down Expand Up @@ -38,8 +39,7 @@ namespace GamescopeWSILayer {
}

static bool contains(const std::vector<const char *> vec, std::string_view lookupValue) {
return std::any_of(vec.begin(), vec.end(),
[=](const char* value) { return value == lookupValue; });
return std::ranges::any_of(vec, std::bind_front(std::equal_to{}, lookupValue));
}

static int waylandPumpEvents(wl_display *display) {
Expand Down Expand Up @@ -762,10 +762,10 @@ namespace GamescopeWSILayer {
pDispatch->PhysicalDevice,
swapchainInfo.surface);

bool supportedSwapchainFormat = std::any_of(
supportedSurfaceFormats.begin(),
supportedSurfaceFormats.end(),
[=](VkSurfaceFormatKHR value) { return value.format == swapchainInfo.imageFormat; });
bool supportedSwapchainFormat = std::ranges::any_of(
supportedSurfaceFormats,
std::bind_front(std::equal_to{}, swapchainInfo.imageFormat),
&VkSurfaceFormatKHR::format);

if (!supportedSwapchainFormat) {
fprintf(stderr, "[Gamescope WSI] Refusing to make swapchain (unsupported VkFormat) for xid: 0x%0x - format: %s - colorspace: %s - flip: %s\n",
Expand Down

0 comments on commit 3401da5

Please sign in to comment.