Answer the question
In order to leave comments, you need to log in
Why doesn't Opera load MP3s in?
The player works fine in all browsers , but in Opera, it gives an error:
undefined:1 Uncaught (in promise) DOMException: Failed to load because no supported source was found.
Answer the question
In order to leave comments, you need to log in
An iterator is an object with pointer semantics that can point to N+1 points in the object.
Since it is with pointer semantics, it has the "unary star" and −> (dereference and dereference + take field) operations. The iterator also has the ++ operation (move to the next position). If this is the so-called. "unidirectional iterator" - everything, nothing more.
There are also so-called. bidirectional iterators (there is a −− operation), and random access iterators (they can be freely added to numbers - well, just like pointers). In particular, std::list has bidirectional iterators.
Iterators have undefined behavior...
• when trying to go beyond the start or end;
• when trying to dereference if it looks at the last position (marked as "end").
Specifically about the task.
1. std::vector is preferred over std::list.
2. No need to return a string*, some container is enough (std::vector<std::string> or std::list<std::string>).
3. If the functionality and speed of istringstream is enough, the flag is in hand! I would write hardcore, from scratch. Here is my code, torn from my project, it will probably be easy to remake it into a training one.
void parseCommaList(
const char *aStart, // указатель на начало
const char *aEnd, // указатель на символ за концом
char aComma, // символ-разделитель
bool aSkipEmpty, // true, если пустые подстроки пропускать
ProcParseCommaList aCallback, // функция-нагрузка
void *aData) // этот параметр нужен, чтобы передавать какие хочешь данные в функцию-нагрузку, удаляй его смело!
{
str::trim(aStart, aEnd); // моя функция; пододвигает aStart вперёд и aEnd назад, убирая пробелы.
// Если удаление пробелов не нужно — удаляй! Если нужно — пиши сам.
if (aStart == aEnd) return;
const char *sstart = aStart;
for (const char *p = aStart; p != aEnd; ++p)
{
if (*p != aComma) continue;
const char *send = p;
str::trim(sstart, send); // то же самое, можно убрать
if (p != sstart || !aSkipEmpty)
aCallback(sstart, send, aData); // замени на боевую нагрузку
sstart = p + 1;
}
str::trim(sstart, aEnd); // то же самое, можно убрать
if (sstart != aEnd || !aSkipEmpty)
aCallback(sstart, aEnd, aData); // замени на боевую нагрузку
}
inline void parseCommaList(
const std::string &aIn,
char aComma,
bool aSkipEmpty,
ProcParseCommaList aCallback,
void *aData)
{
parseCommaList(aIn.data(), aIn.data() + aIn.length(), aComma, aSkipEmpty,
aCallback, aData);
}
If not difficult, explain in Russian what an iterator is
For example like so stackoverflow.com/questions/236129/split-a-string-in-c
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question