#include "utility/string.hpp"
#pragma once #include <string> #include <iterator> #include <algorithm> #include "internal/dev_env.hpp" namespace uni { template<std::input_iterator I, std::sentinel_for<I> S, class Res = std::string> Res to_lower(I first, S last) noexcept(NO_EXCEPT) { Res res; res.reserve(std::ranges::distance(first, last)); std::ranges::transform(first, last, std::back_inserter(res), ::tolower); return res; } template<std::input_iterator I, std::sentinel_for<I> S, class Res = std::string> Res to_uppwer(I first, S last) noexcept(NO_EXCEPT) { Res res; res.reserve(std::ranges::distance(first, last)); std::ranges::transform(first, last, std::back_inserter(res), ::toupper); return res; } template<class Res = std::string> Res to_lower(const std::string str) noexcept(NO_EXCEPT) { return to_lower<std::string::const_iterator, std::string::const_iterator, Res>(std::begin(str), std::end(str)); } template<class Res = std::string> Res to_uppwer(const std::string str) noexcept(NO_EXCEPT) { return to_uppwer<std::string::const_iterator, std::string::const_iterator, Res>(std::begin(str), std::end(str)); } } // namespace uni
#line 2 "utility/string.hpp" #include <string> #include <iterator> #include <algorithm> #line 2 "internal/dev_env.hpp" #ifdef LOCAL_JUDGE inline constexpr bool DEV_ENV = true; inline constexpr bool NO_EXCEPT = false; #else inline constexpr bool DEV_ENV = false; inline constexpr bool NO_EXCEPT = true; #endif // LOCAL_JUDGE #if __cplusplus >= 202100L #define CPP20 true #define CPP23 true #elif __cplusplus >= 202002L #define CPP20 true #define CPP23 false #else #define CPP20 false #define CPP23 false #endif #line 10 "utility/string.hpp" namespace uni { template<std::input_iterator I, std::sentinel_for<I> S, class Res = std::string> Res to_lower(I first, S last) noexcept(NO_EXCEPT) { Res res; res.reserve(std::ranges::distance(first, last)); std::ranges::transform(first, last, std::back_inserter(res), ::tolower); return res; } template<std::input_iterator I, std::sentinel_for<I> S, class Res = std::string> Res to_uppwer(I first, S last) noexcept(NO_EXCEPT) { Res res; res.reserve(std::ranges::distance(first, last)); std::ranges::transform(first, last, std::back_inserter(res), ::toupper); return res; } template<class Res = std::string> Res to_lower(const std::string str) noexcept(NO_EXCEPT) { return to_lower<std::string::const_iterator, std::string::const_iterator, Res>(std::begin(str), std::end(str)); } template<class Res = std::string> Res to_uppwer(const std::string str) noexcept(NO_EXCEPT) { return to_uppwer<std::string::const_iterator, std::string::const_iterator, Res>(std::begin(str), std::end(str)); } } // namespace uni