utils: Satisfy LegacyInputIterator with StringSplitter::iterator
The StringSplitter::iterator is used with the utils::split() function to iterate over components of a split string. Add the necessary member types expected by std::iterator_trait in order to satisfy the LegacyInputIterator requirement and make the iterator usable in constructors for various containers. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
This commit is contained in:
parent
a17f0eddc6
commit
a7d3570e7c
2 changed files with 14 additions and 0 deletions
|
@ -170,6 +170,12 @@ public:
|
|||
class iterator
|
||||
{
|
||||
public:
|
||||
using difference_type = std::size_t;
|
||||
using value_type = std::string;
|
||||
using pointer = value_type *;
|
||||
using reference = value_type &;
|
||||
using iterator_category = std::input_iterator_tag;
|
||||
|
||||
iterator(const StringSplitter *ss, std::string::size_type pos);
|
||||
|
||||
iterator &operator++();
|
||||
|
|
|
@ -276,6 +276,14 @@ protected:
|
|||
return TestFail;
|
||||
}
|
||||
|
||||
const auto &split = utils::split(path, ":");
|
||||
dirs = std::vector<std::string>{ split.begin(), split.end() };
|
||||
|
||||
if (dirs != elements) {
|
||||
cerr << "utils::split() LegacyInputIterator test failed" << endl;
|
||||
return TestFail;
|
||||
}
|
||||
|
||||
/* utils::join() with conversion function test. */
|
||||
std::vector<Size> sizes = { { 0, 0 }, { 100, 100 } };
|
||||
s = utils::join(sizes, "/", [](const Size &size) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue