/* * Mirai. Copyright (C) 2024 Vyn * This file is licensed under version 3 of the GNU General Public License (GPL-3.0-only) * The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt */ #pragma once #include #include #include #include #include namespace mirai { namespace stringUtils = cpputils::string; namespace vectorUtils = cpputils::vector; bool isDate(const std::string &dateStr); template T *ptrFindFirst(std::vector &container, F f) { auto element = std::ranges::find_if(container, f); if (element == container.end()) { return nullptr; } return &(*element); } // TODO use ref for container first arg template std::optional findFirst(std::vector container, F f) { auto element = std::ranges::find_if(container, f); if (element == container.end()) { return std::nullopt; } return *element; } template std::vector findAll(std::vector container, F f) { std::vector result; std::ranges::copy_if(container, std::back_inserter(result), f); return result; } int generateUniqueId(); } // namespace mirai