felixguendling / cista

Cista is a simple, high-performance, zero-copy C++ serialization & reflection library.
https://cista.rocks
MIT License
1.78k stars 113 forks source link

cista::vector erase(iterator) on its.end() element stability #142

Closed ChemistAion closed 2 years ago

ChemistAion commented 2 years ago

I know that cista::vector follows "Currently, they do not provide exactly the same interface as their std:: equivalents." but I would like to report this anyway.

When cista::vector.erase(iterator) is updated from its previous result then the vector last element (of more than one in total) will be not considered in such a loop:

    CISTA::vector<int> test_cista;
    test_cista.push_back(1);
    test_cista.push_back(2);

    for (auto iterator = test_cista.begin(); iterator != test_cista.end(); iterator)
    {
        iterator = test_cista.erase(iterator);
        continue;
    }

With one element in cista::vector only works fine: https://godbolt.org/z/r8E57hs4s

felixguendling commented 2 years ago

Thank you! This should be fixed in https://github.com/felixguendling/cista/commit/3a91caedba6841c0d5141795709affe89015e4de

ChemistAion commented 2 years ago

Fix confirmed with MSVC 17.3.1 x64 [Visual Studio 2022 (v143)] Thank you for prompt action here.