#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; }