Trim String Characters With Boost Lambda

#include <boost/algorithm/string.hpp>

wstring s = L"\"quoted\"";

boost::algorithm::trim_if(this->open_cmd,
                          [](auto& ch) { return ch == L'\"'; });

produces output quoted.

The beauty here is using C++11 lambdas with boost algorithms instead of static methods or function objects making syntax super short.


To contact me, send an email anytime or leave a comment below.