MCPcopy Create free account
hub / github.com/boostorg/json / insert

Method insert

include/boost/json/impl/string.hpp:79–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77// FowardIterator or better, as we can use std::distance
78template<class InputIt, class>
79auto
80string::
81insert(
82 size_type pos,
83 InputIt first,
84 InputIt last) ->
85 string&
86{
87 struct cleanup
88 {
89 detail::string_impl& s;
90 storage_ptr const& sp;
91
92 ~cleanup()
93 {
94 s.destroy(sp);
95 }
96 };
97
98 // We use the default storage because
99 // the allocation is immediately freed.
100 storage_ptr dsp;
101 detail::string_impl tmp(
102 first, last, dsp,
103 iter_cat<InputIt>{});
104 cleanup c{tmp, dsp};
105 std::memcpy(
106 impl_.insert_unchecked(pos, tmp.size(), sp_),
107 tmp.data(),
108 tmp.size());
109 return *this;
110}
111
112// KRYSTIAN TODO: this can be done without copies when
113// reallocation is not needed, when the iterator is a

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected