From 7307815e99a79dac42f2a9c06b0fe6171ea11ba0 Mon Sep 17 00:00:00 2001 From: HampusM Date: Fri, 1 Jul 2022 16:01:04 +0200 Subject: refactor: use ranges --- src/util/algorithm_impl.hpp | 67 --------------------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 src/util/algorithm_impl.hpp (limited to 'src/util/algorithm_impl.hpp') diff --git a/src/util/algorithm_impl.hpp b/src/util/algorithm_impl.hpp deleted file mode 100644 index d7c5e3b..0000000 --- a/src/util/algorithm_impl.hpp +++ /dev/null @@ -1,67 +0,0 @@ -#pragma once - -#include "algorithm.hpp" - -#include - -template -requires Container -constexpr auto container_find(const ContainerType &container, const Value &value) noexcept - -> typename ContainerType::const_iterator -{ - return std::find(container.begin(), container.end(), value); -} - -template -requires Container && - std::predicate -constexpr auto -container_find(const ContainerType &container, Predicate predicate) noexcept -> - typename ContainerType::const_iterator -{ - return std::find_if(container.begin(), container.end(), predicate); -} - -template -requires Container -constexpr auto container_has(const ContainerType &container, const Value &value) noexcept - -> bool -{ - return container_find(container, value) != container.end(); -} - -template -requires Container && HasPushBack && - std::predicate -constexpr auto -container_filter(const ContainerType &container, Predicate predicate) noexcept - -> ContainerType -{ - ContainerType filtered_container; - - std::copy_if( - std::begin(container), - std::end(container), - std::back_inserter(filtered_container), - predicate); - - return filtered_container; -} - -template -requires Container && - std::predicate -constexpr auto -container_filter(const ContainerType &container, Predicate predicate) noexcept - -> ContainerType -{ - ContainerType filtered_container; - - std::copy_if( - std::begin(container), - std::end(container), - std::inserter(filtered_container, filtered_container.begin()), - predicate); - - return filtered_container; -} -- cgit v1.2.3-18-g5258