Skip to content

DNKpp/Simple-Iterator

Repository files navigation

Simple-Iterator C++20 library

windows msvc windows clang-cl ubuntu clang ubuntu gcc
Build & Test - MSVC Build & Test - Clang-Cl Build & Test - Clang-10 Build & Test - GCC-10
Build & Test - Clang-11 Build & Test - GCC-11
Build & Test - Clang-12

Codacy Badge

Author

Dominic Koepke
Mail: DNKpp2011@gmail.com

License

BSL-1.0 (free, open source)

          Copyright Dominic Koepke 2021 - 2021.
 Distributed under the Boost Software License, Version 1.0.
    (See accompanying file LICENSE_1_0.txt or copy at
          https://www.boost.org/LICENSE_1_0.txt)

Description

This library provides an iterator_interface class, which aims to reduce the boilerplate needed for c++20 iterator like classes. Users must simply inherit from that class, provide some minimal template arguments and implement a minimal amount of methods (depending on the aimed category) until the custom iterator is ready for use. Everything is checked via concepts, thus it should be quite easy to find the missing or wrong parts in your definition. Have a look into the wiki, if you need a more in depth explanation or simply some examples.

I took the new std::ranges::view_interface as an inspiration how to design such a class.

Be aware that many clang and gcc versions doesn't finally support all used c++20 features. Have a look at the badges on top, to get an idea which one might fit.

Installation with CMake

This library can easily be integrated into your project via CMake target_link_libraries command.

target_link_libraries(
	<your_target_name>
	PRIVATE
	simple_iterator
)

This will add the the include path "<simple_iterator_install_dir>/include", thus you are able to include the headers via

#include <Simple-Iterator/iterator_interface.hpp>

FetchContent

It is possible fetching this library via CMakes FetchContent module.

cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

project(<your_project_name>)

include(FetchContent)

FetchContent_Declare(
	simple_iterator
	GIT_REPOSITORY	https://github.com/DNKpp/Simple-Iterator
	GIT_TAG		origin/v1.x
)
FetchContent_MakeAvailable(simple_iterator)

target_link_libraries(
	<your_target_name>
	PRIVATE simple_iterator
)