Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update utils.h to include <limits> #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions src/utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include "options.h"
#include <limits>

#include "options.h"
#include "miniz/miniz.h"

/**
Expand Down Expand Up @@ -201,15 +202,22 @@ inline bool parse_boolstring(const std::string &value) { return value == "true";

inline double double_min() { return std::numeric_limits<double>::min(); }

static inline std::string &ltrim(std::string &s) {
s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
return s;
// trim from start
static inline std::string& ltrim(std::string &s)
{
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch)
{ return !std::isspace(ch); }));
return s;
}

// trim from end
static inline std::string &rtrim(std::string &s) {
s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
return s;
static inline std::string& rtrim(std::string &s)
{
s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch)
{ return !std::isspace(ch); })
.base(),
s.end());
return s;
}

// trim from both ends
Expand Down