plf_list
plf_list copied to clipboard
splicing the last element to the end drops it
Calling splice() to move the last element to the end drops it
#include <iostream>
#include "plf_list.h"
void print(const plf::list<int>& list1)
{
for (auto& elem : list1)
{
std::cout << elem << ' ';
}
std::cout << std::endl;
}
int main()
{
plf::list<int> list1 = { 1, 2, 3, 4, 5 };
// Outputs "1 2 3 4 5 "
print(list1);
// This *should* be a no-op:
list1.splice(list1.end(), std::prev(list1.end()));
// Outputs "1 2 3 4"
print(list1);
return 0;
}
Update: Similarly, splicing to the beginning has the same issue. If you replace the splice() call above with
list1.splice(list1.begin(), list1.begin());
Then the list ends up being: "2 3 4 5"
Thanks, will fix-
On Wed, 30 Mar 2022 at 12:07, Chris Scrimgeour @.***> wrote:
Update: Similarly, splicing to the beginning has the same issue. If you replace the splice() call above with
list1.splice(list1.begin(), list1.begin());
Then the list ends up being: "2 3 4 5"
— Reply to this email directly, view it on GitHub https://github.com/mattreecebentley/plf_list/issues/22#issuecomment-1082454303, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABE4FIRNFPX6AHZQRH7FHIDVCOEJNANCNFSM5R75SVRA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Fixed now - please double-check though