MCPcopy Create free account
hub / github.com/ChaiScript/ChaiScript / insert_at

Function insert_at

include/chaiscript/dispatchkit/bootstrap_stl.hpp:143–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141 /// Algorithm for inserting at a specific position into a container
142 template<typename Type>
143 void insert_at(Type &container, int pos, const typename Type::value_type &v)
144 {
145 auto itr = container.begin();
146 auto end = container.end();
147
148 if (pos < 0 || std::distance(itr, end) < pos)
149 {
150 throw std::range_error("Cannot insert past end of range");
151 }
152
153 std::advance(itr, pos);
154 container.insert(itr, v);
155 }
156
157
158 /// Algorithm for erasing a specific position from a container

Callers

nothing calls this directly

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected