cpp msic


cpp misc

std::set iterate方法

// Set of strings
std::setstring> setOfStr = {
                            "jjj",
                            "khj",
                            "bca",
                            "aaa",
                            "ddd" };
// Creating a iterator pointing to start of set
std::setstring>::iterator it = setOfStr.begin();
// Iterate till the end of set
while (it != setOfStr.end())
{
    // Print the element
    std::cout << (*it) << " , ";
    //Increment the iterator
    it++;
}

from: https://thispointer.com/different-ways-to-iterate-over-a-set-in-c/

cpp