MCPcopy Create free account
hub / github.com/ashvardanian/StringZilla / try_reserve

Method try_reserve

include/stringzilla/stringzilla.hpp:3420–3425  ·  view source on GitHub ↗

* @brief Attempts to reserve enough space for a specified number of characters. * @param[in] capacity The new capacity to reserve. * @return `true` if the reservation was successful, `false` otherwise. */

Source from the content-addressed store, hash-verified

3418 * @return `true` if the reservation was successful, `false` otherwise.
3419 */
3420 bool try_reserve(size_type capacity) noexcept {
3421 auto status = _with_alloc([&](sz_alloc_type &alloc) {
3422 return sz_string_reserve(&string_, capacity, &alloc) ? sz_success_k : sz_bad_alloc_k;
3423 });
3424 return status == status_t::success_k;
3425 }
3426
3427 /**
3428 * @brief Assigns a new value to the string, replacing its current contents.

Callers

nothing calls this directly

Calls 2

_with_allocFunction · 0.85
sz_string_reserveFunction · 0.85

Tested by

no test coverage detected