MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / substr

Function substr

example/cacheHierarchy/fkYAML/node.hpp:2452–2458  ·  view source on GitHub ↗

@brief Constructs a sub basic_str_view object from `pos` by `n` size. @warning Throws an fkyaml::out_of_range exception if the given `pos` is bigger than the length. @param pos The offset of the beginning position. @param n The number of elements to the end of a new sub basic_str_view object. @return A newly created sub basic_str_view object.

Source from the content-addressed store, hash-verified

2450 /// @param n The number of elements to the end of a new sub basic_str_view object.
2451 /// @return A newly created sub basic_str_view object.
2452 basic_str_view substr(size_type pos = 0, size_type n = npos) const {
2453 if FK_YAML_UNLIKELY (pos > m_len) {
2454 throw fkyaml::out_of_range(static_cast<int>(pos));
2455 }
2456 const size_type rlen = std::min(n, m_len - pos);
2457 return basic_str_view(mp_str + pos, rlen);
2458 }
2459
2460 /// @brief Compares the referenced character sequence values with the given basic_str_view object.
2461 /// @param sv The basic_str_view object to compare with.

Callers 2

compareFunction · 0.85
starts_withFunction · 0.85

Calls 2

out_of_rangeClass · 0.85
basic_str_viewFunction · 0.85

Tested by

no test coverage detected