Commit c2cf0423 authored by Tom Niget's avatar Tom Niget

Add some useful functions to PyStr

parent 4600fea0
......@@ -12,7 +12,7 @@ using namespace std::literals;
#include "bytes.hpp"
#include "print.hpp"
//#include <format>
// #include <format>
#include <fmt/format.h>
class PyStr : public std::string {
......@@ -22,6 +22,7 @@ public:
PyStr(const std::string &s) : std::string(s) {}
PyStr(std::string &&s) : std::string(std::move(s)) {}
PyStr(size_t count, char ch) : std::string(count, ch) {}
constexpr PyStr(const char *s, size_t count) : std::string(s, count) {}
template <class InputIterator>
PyStr(InputIterator first, InputIterator last) : std::string(first, last) {}
......@@ -33,6 +34,8 @@ public:
template <typename... T> PyStr format(T &&...args) const {
return PyStr(fmt::format(fmt::runtime(*this), std::forward<T>(args)...));
}
bool startswith(const std::string &s) const { return this->starts_with(s); }
};
inline constexpr PyStr operator""_ps(const char *s, size_t len) noexcept {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment