// // Created by max on 19.08.22. // #ifndef PDS_UTILITY_HPP #define PDS_UTILITY_HPP #include namespace pds { template void unused(T&&...) { } struct noop { // https://stackoverflow.com/a/31275330 struct anything { template operator T(){ return {}; } // optional reference support. Somewhat evil. template operator T&()const{ static T t{}; return t; } }; template anything operator()(Args&&...)const{return {};} template operator std::function() { return [](auto&&...){}; } }; template inline void ltrim(std::basic_string& s) { s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](const CharT c) { return !std::isspace(c); })); } static const noop noop_v = {}; template inline void rtrim(std::basic_string& s) { s.erase(std::find_if(s.rbegin(), s.rend(), [](const CharT c) { return !std::isspace(c); }).base(), s.end()); } template inline void trim(std::basic_string& s) { ltrim(s); rtrim(s); } } #endif //PDS_UTILITY_HPP