From 3c2c2d605a58064bb160045157644ab440601b8c Mon Sep 17 00:00:00 2001 From: SCG82 Date: Tue, 10 Dec 2019 07:34:12 -0800 Subject: [PATCH] use C++11 --- Makefile | 3 ++- src/Dependency.cpp | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index d06633d..7e77831 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ DESTDIR= PREFIX=/usr/local -CXXFLAGS = -O2 +CXX=clang++ +CXXFLAGS=-O2 -std=c++11 all: dylibbundler diff --git a/src/Dependency.cpp b/src/Dependency.cpp index 32efff0..4dddb31 100644 --- a/src/Dependency.cpp +++ b/src/Dependency.cpp @@ -44,8 +44,20 @@ std::string stripPrefix(std::string in) return in.substr(in.rfind("/")+1); } -std::string& rtrim(std::string &s) { - s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun(std::isspace))).base(), s.end()); +// std::string& rtrim(std::string &s) { +// s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun(std::isspace))).base(), s.end()); +// return s; +// } + +static inline void rtrim_in_place(std::string &s) { + s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) { + return !std::isspace(ch); + }).base(), s.end()); +} + +// trim from end (copying) +static inline std::string rtrim(std::string s) { + rtrim_in_place(s); return s; }