A C++ string algorithm library.
Use PACC package manager.
Add string-algo@0.1.0
to dependencies
field of your cpackage.json
:
"dependencies": [
"string-algo@0.1.0"
]
Run the following shell command:
pacc install
Include the header file:
#include <StringAlgo/Everything.hpp>
You may want to create a namespace alias, for example:
namespace sa = string_algo;
constexpr std::string_view toAnalyze = "The quick brown fox jumps over the lazy dog";
for(std::string_view v : sa::StringTokenIterator(toAnalyze, " "))
{
std::cout << v << "\n";
}
Output:
The
quick
brown
fox
jumps
over
the
lazy
dog
constexpr std::string_view str = "-41423";
std::optional<int> i = sa::to<int>(str);
if (i.has_value())
std::cout << "i: " << *i << std::endl;
// Without optional
int j;
if (sa::to<int>(j, str))
{
std::cout << "j: " << j << std::endl;
}
Paweł Syska