11 template<
class... Ts>
struct overloaded : Ts... {
using Ts::operator()...; };
40 static constexpr size_t strlen(
const char* str) {
47 bool going_down =
true;
49 std::visit([](
const auto& n) {
59 std::visit([&](
const auto& n){
66 std::visit([&](
const auto& n){
78 memcpy(buffer+off, s.c_str, s.size);
84 const auto& c = std::get<concat_t>(*r);
85 if (c.temp_left && c.right) {
87 std::visit([&](
const auto& n){
100 void append(
rope_node* rn,
bool use_left=
false) {
101 auto cc = std::get_if<concat_t>(rn);
102 eosio::check(cc,
"append should only allow concat nodes");
111 void at(
char& ret,
size_t index,
rope_node* rn,
size_t& index_so_far,
bool& stop) {
117 at(ret, index, c.left, index_so_far, stop);
119 at(ret, index, c.right, index_so_far, stop);
122 [&](
const str_t& s) {
123 index_so_far -= s.size;
124 if (index >= index_so_far) {
125 ret = s.c_str[index-index_so_far];
140 rope(std::string_view s =
"") {
146 inline constexpr void append(
const char (&s)[N]) {
157 constexpr char at(
size_t index) {
161 at(ret, index, root, sz, stop);
166 append(r.root,
true);
171 append(r.root,
true);
180 append(s, strlen(s)-1);
189 append(std::move(r));
204 lhs += std::move(rhs);
218 char* ret =
new char[size+1];
221 c_str(ret, root, off);
227 std::string_view
sv()
const {
228 return {
c_str(), size};