Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 19, 2025

Implements missing vector::insert(const_iterator pos, InputIt first, InputIt last) method for kf::vector to enable range insertion.

Changes

Implementation (include/kf/stl/vector)

  • Added template method accepting InputIterator range [first, last)
  • Uses std::distance to calculate element count for pre-allocation via reallocateGrowth
  • Returns std::optional<iterator> (nullopt on allocation failure)
  • Added #include <iterator> for std::distance

Tests (test/Vector.cpp)

  • Insert range from array/vector into empty vector
  • Insert range at beginning/middle/end of populated vector
  • Insert empty range (edge case)

Usage

kf::vector<int, PagedPool> v;
REQUIRE_NT_SUCCESS(v.push_back(1));
REQUIRE_NT_SUCCESS(v.push_back(5));

int arr[] = {2, 3, 4};
auto iter = v.insert(v.begin() + 1, std::begin(arr), std::end(arr));
// v is now [1, 2, 3, 4, 5]
Original prompt

This section details on the original issue you should resolve

<issue_title>Add vector::insert for a range [first, last)</issue_title>
<issue_description>- Implement a missing method in kf::vector: iterator insert(const_iterator pos, InputIt first, InputIt last).

  • Look how other methods are implemented and follow the same principle.
  • Note: it's a widows kernel-mode code, so it doesn't support C++ exceptions.
  • Add a test for the new method (look for existing tests and do the same).</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add vector::insert for a range [first, last) Add vector::insert for iterator range [first, last) Dec 19, 2025
Copilot AI requested a review from SergiusTheBest December 19, 2025 17:16
@SergiusTheBest SergiusTheBest marked this pull request as ready for review December 19, 2025 17:37
@SergiusTheBest SergiusTheBest merged commit 9c3bcdc into main Dec 19, 2025
2 checks passed
@SergiusTheBest SergiusTheBest deleted the copilot/add-vector-insert-range branch December 19, 2025 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add vector::insert for a range [first, last)

2 participants