Skip to content

Concat multiple C++ containers to a single iterable object

Notifications You must be signed in to change notification settings

erikzenker/chainiterator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chain Iterator

Build Status codecov

Chain Iterator is a C++ class which concats multiple C++ containers to a single iterable object.

Usage

// STL
#include <iostream>
#include <vector>
#include <array>
#include <list>

#include <ChainIterator.h>

int main()
{
    std::vector<int> a{ 1, 2 };
    std::vector<int> b{ 3, 4 };
    std::array<int, 2> c{ 5, 6 };
    std::list<int> d{ 7, 8 };

    auto chainIterator = makeChainIterator(a,b,c,d);

    for(auto& element : chainIterator){
        std::cout << element << std::endl;
    }

    return 0;
}

Output:

1
2
3
4
5
6
7
8

Build Example

mkdir build; cd build
cmake ..
cmake --build chainiterator_example
./example/chainiterator_example

Build Tests

mkdir build; cd build
cmake ..
cmake --build chainiterator_unit_test
./test/unit/chainiterator_unit_test

Dependencies

  • boost 1.67
  • c++14

Licence

MIT

Author

Written by Erik Zenker (erikzenker (at) hotmail.com)

About

Concat multiple C++ containers to a single iterable object

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published