diff --git a/docs/unstable/bc_s.png b/docs/unstable/bc_s.png new file mode 100644 index 0000000..224b29a Binary files /dev/null and b/docs/unstable/bc_s.png differ diff --git a/docs/unstable/bc_sd.png b/docs/unstable/bc_sd.png new file mode 100644 index 0000000..31ca888 Binary files /dev/null and b/docs/unstable/bc_sd.png differ diff --git a/docs/unstable/changelog.html b/docs/unstable/changelog.html new file mode 100644 index 0000000..5498bac --- /dev/null +++ b/docs/unstable/changelog.html @@ -0,0 +1,194 @@ + + +
+ + + + +
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
This is Version 1.2.0 of Itertools, a single-header library for adapting C++ ranges.
+We thank all contributors: Thomas Hahn, Alexander Hampel, Olivier Parcollet, Dylan Simon, Nils Wentzell
+Find below an itemized list of changes in this release.
+This is Version 1.1.0 of Itertools, a single-header library for adapting C++ ranges.
+We thank all contributors: Daniel Bauernfeind, Alexander Hampel, Dylan Simon, Nils Wentzell
+Find below an itemized list of changes in this release.
+Itertools Version 1.0.0 is a single-header C++ library that allows, with a simple interface, for the writing of various types of range-based for loops.
+This is the initial release for this project.
+
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
This is the complete list of members for range, including all inherited members.
+all | range | inlinestatic |
begin() const noexcept | range | inline |
cbegin() const noexcept | range | inline |
cend() const noexcept | range | inline |
end() const noexcept | range | inline |
first() const | range | inline |
index_t typedef | range | |
last() const | range | inline |
operator+(long shift) const | range | inline |
operator<< | range | friend |
operator==(range const &) const =default | range | |
range()=default | range | |
range(long first, long last) noexcept | range | inline |
range(long first, long last, long step) | range | inline |
range(long last) | range | inlineexplicit |
size() const | range | inline |
step() const | range | inline |
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
#include <itertools/range.hpp>
A lazy range of integers that mimics a Python range.
+It stores the first value, the last value (excluded) and the step size between two indices. By default, the step size is set to 1. This function returns an iterable lazy object, which can be used in range-based for loops:
+Output:
+See also std::ranges::views::iota.
+ + ++Classes | |
struct | all_t |
Denote a full range at compile-time. More... | |
struct | const_iterator |
Const iterator type for itertools::range. More... | |
+Public Types | |
using | index_t = long |
Integer type for backward compatibility. | |
+Public Member Functions | |
range ()=default | |
Default constructor. | |
range (long first, long last) noexcept | |
Construct a range with a step size of 1 and a given first and last (excluded) value. | |
range (long first, long last, long step) | |
Construct a range with a given step size and a given first and last (excluded) value. | |
range (long last) | |
Construct a range with a step size of 1, a first value set to 0 and a given last value (excluded). | |
const_iterator | begin () const noexcept |
The same as cbegin(). | |
const_iterator | cbegin () const noexcept |
Beginning of the integer range. | |
const_iterator | cend () const noexcept |
End of the range. | |
const_iterator | end () const noexcept |
The same as cend(). | |
long | first () const |
Get first value of the range. | |
long | last () const |
Get last value of the range (excluded). | |
range | operator+ (long shift) const |
Shift the whole range by a given amount. | |
+bool | operator== (range const &) const =default |
Default equal-to operator. | |
long | size () const |
Get number of elements in the range. | |
long | step () const |
Get step size between two elements of the range. | |
+Static Public Attributes | |
static constexpr all_t | all = {} |
See range::all_t. | |
+Friends | |
std::ostream & | operator<< (std::ostream &os, const range &rg) |
Write the range details to std::ostream. | |
using index_t = long | +
+
|
+ +default | +
Default constructor.
+
+
|
+ +inlinenoexcept | +
+
|
+ +inline | +
Construct a range with a given step size and a given first and last (excluded) value.
+Throws an exception if the step size is zero.
+first | First value of the range. |
last | Last value of the range (excluded). |
step | Number of integers between two elements of the range. |
+
|
+ +inlineexplicit | +
+
|
+ +inlinenoexcept | +
+
|
+ +inlinenoexcept | +
+
|
+ +inlinenoexcept | +
+
|
+ +inlinenoexcept | +
+
|
+ +inline | +
+
|
+ +inline | +
+
|
+ +inline | +
+
|
+ +inline | +
+
|
+ +inline | +
+
|
+ +friend | +
+
|
+ +inlinestaticconstexpr | +
See range::all_t.
+ + + +
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
+Files | |
enumerate.hpp | |
Provides a range adapting function for enumerating a given range/view. | |
iterator_facade.hpp | |
Provides a CRTP base class for various iterator types in itertools. | |
itertools.hpp | |
Provides a small subset of the ranges and views from std::ranges. | |
omp_chunk.hpp | |
Provides utilities to distribute a range across OMP threads. | |
product.hpp | |
Provides a range adapting function for multiplying a given number of ranges/views (cartesian product). | |
range.hpp | |
Provides an integer range similar to Python's range. | |
sentinel.hpp | |
Provides a generic sentinel type for various iterator types in itertools. | |
slice.hpp | |
Provides a range adapting function for slicing a given range/view. | |
stride.hpp | |
Provides a range adapting function for striding through a given range/view. | |
transform.hpp | |
Provides a range adapting function for transforming a given range/view. | |
utils.hpp | |
Provides some utility functions for itertools. | |
zip.hpp | |
Provides a range adapting function for zipping a given number of ranges/views. | |
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
The following provides a detailed reference documentation grouped into logical units.
+For most users of the library it should be sufficient to either use one of the Range adapting functions or an Integer range.
+If you are looking for a specific function, class, etc., try using the search bar in the top left corner.
+Range adapting functions take one or more existing ranges and return lazy Adapted ranges that can be iterated over. Lazy means that new elements are produced on the fly whenever they are needed instead of being precomputed when the range is created.
+The following range adpating functions are available in itertools:
+ +Adapted ranges are returned by the range adapting functions and can be iterated over using one of the Range iterators. In most cases, the user will never have to create or modify an adapted range directly. Instead, it is recommended to simply use the provided Range adapting functions.
+The following adapted ranges are defined in itertools:
+Range iterators are internally used by the library to iterate over Adapted ranges. In general, there should be no need for users to deal with range iterators directly. Instead, it is recommended to use range-based for loops, e.g.
vs. the traditional for loops, e.g.
The following range iterators are defined in itertools:
+ +An Integer range is similar to a Python range
. It is defined by a start value, an end value and a step size such that the i-th value of the range is given by start + i * step
.
The following classes and functions related to integer ranges are defined in itertools:
+Utilities are mostly internal implementation details and should not concern everyday users. The only functions the might be intersting to some users are: chunk_range, make_vector_from_range and omp_chunk.
+The following utilities are defined in itertools:
+ +
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
#include "./iterator_facade.hpp"
#include "./sentinel.hpp"
#include <iterator>
#include <tuple>
#include <utility>
Provides a range adapting function for enumerating a given range/view.
+ +Definition in file enumerate.hpp.
+Go to the source code of this file.
++Classes | |
struct | enum_iter< Iter > |
Iterator for a detail::enumerated range. More... | |
struct | enumerated< R > |
Represents an enumerated range. More... | |
+Functions | |
template<typename R > | |
detail::enumerated< R > | enumerate (R &&rg) |
Lazy-enumerate a given range (similar to Python's enumerate). | |
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
In this example, we compare itertools's adapted ranges with their counterparts from std::ranges
.
Output:
+
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
All examples have been compiled on a MacBook Pro with an Apple M2 Max chip. At the point of writing this documentation only gcc-13 has implemented the required std::ranges
for some of the examples. We therefore used gcc 13.2.0 together with cmake 3.27.2.
Assuming that the actual example code is in a file main.cpp
and that the print.hpp
(see below) is in the same directory, the following generic CMakeLists.txt
should work for all examples:
To print the elements of a range to stdout
, we used the following header:
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
▼ itertools | |
enumerate.hpp | Provides a range adapting function for enumerating a given range/view |
iterator_facade.hpp | Provides a CRTP base class for various iterator types in itertools |
itertools.hpp | Provides a small subset of the ranges and views from std::ranges |
omp_chunk.hpp | Provides utilities to distribute a range across OMP threads |
product.hpp | Provides a range adapting function for multiplying a given number of ranges/views (cartesian product) |
range.hpp | Provides an integer range similar to Python's range |
sentinel.hpp | Provides a generic sentinel type for various iterator types in itertools |
slice.hpp | Provides a range adapting function for slicing a given range/view |
stride.hpp | Provides a range adapting function for striding through a given range/view |
transform.hpp | Provides a range adapting function for transforming a given range/view |
utils.hpp | Provides some utility functions for itertools |
zip.hpp | Provides a range adapting function for zipping a given number of ranges/views |
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
Adapted ranges are returned by the range adapting functions and can be iterated over using one of the Range iterators.
+In most cases, the user will never have to create or modify an adapted range directly. Instead, it is recommended to simply use the provided Range adapting functions.
++Classes | |
struct | enumerated< R > |
Represents an enumerated range. More... | |
struct | multiplied< Rs > |
Represents a cartesian product of ranges. More... | |
struct | sliced< R > |
Represents a sliced range. More... | |
struct | strided< R > |
Represents a strided range. More... | |
struct | transformed< R, F > |
Represents a transformed range. More... | |
struct | zipped< Rs > |
Represents a zipped range. More... | |
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
An integer range is similar to a Python range
.
It is defined by a start value, an end value and a step size such that the i-th value of the range is given by start + i * step
.
+Classes | |
class | range |
A lazy range of integers that mimics a Python range. More... | |
struct | range::all_t |
Denote a full range at compile-time. More... | |
struct | range::const_iterator |
Const iterator type for itertools::range. More... | |
+Functions | |
template<typename F > | |
void | foreach (range const &rg, F &&f) |
Apply a function to every element of an integer itertools::range. | |
template<typename... Is, typename EnableIf = std::enable_if_t<(std::is_integral_v<Is> and ...), int>> | |
auto | product_range (Is... is) |
Create a cartesian product range of integer ranges from given integers. | |
template<typename I , size_t N, typename EnableIf = std::enable_if_t<std::is_integral_v<I>, int>> | |
auto | product_range (std::array< I, N > const &idx_arr) |
Create a cartesian product range of integer ranges from an array of integers. | |
template<typename... Is, typename EnableIf = std::enable_if_t<(std::is_integral_v<Is> and ...), int>> | |
auto | product_range (std::tuple< Is... > const &idx_tpl) |
Create a cartesian product range of integer ranges from a tuple of integers. | |
void foreach | +( | +range const & | rg, | +
+ | + | F && | f ) | +
#include <itertools/range.hpp>
Apply a function to every element of an integer itertools::range.
+Output:
+F | Callable type. |
rg | itertools::range object. |
f | Callable object to be applied to each element. |
auto product_range | +( | +Is... | is | ) | ++ |
#include <itertools/range.hpp>
Create a cartesian product range of integer ranges from given integers.
+The given integers specify the excluded last values of the individual itertools::range objects. Each range starts at 0 and has a step size of 1.
+Output:
+Is | Integer types. |
is | Last values of the integer ranges (excluded). |
auto product_range | +( | +std::array< I, N > const & | idx_arr | ) | ++ |
#include <itertools/range.hpp>
Create a cartesian product range of integer ranges from an array of integers.
+The integers in the given array specify the excluded last values of the individual itertools::range objects. Each range starts at 0 and has a step size of 1.
+Output:
+I | Integer type. |
N | Number of elements in the array. |
idx_arr | Array containing the excluded last values of the integer ranges. |
auto product_range | +( | +std::tuple< Is... > const & | idx_tpl | ) | ++ |
#include <itertools/range.hpp>
Create a cartesian product range of integer ranges from a tuple of integers.
+The integers in the given tuple specify the excluded last values of the individual itertools::range objects. Each range starts at 0 and has a step size of 1.
+Output:
+Is | Integer types. |
idx_tpl | Tuple containing the excluded last values of the integer ranges. |
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
Range adapting functions take one or more existing ranges and return lazy Adapted ranges that can be iterated over.
+Lazy means that new elements are produced on the fly whenever they are needed instead of being precomputed when the range is created.
++Functions | |
template<typename R > | |
detail::enumerated< R > | enumerate (R &&rg) |
Lazy-enumerate a given range (similar to Python's enumerate). | |
template<typename R , size_t N> | |
auto | make_product (std::array< R, N > &arr) |
Create a cartesian product range from an array of ranges. | |
template<typename R , size_t N> | |
auto | make_product (std::array< R, N > const &arr) |
Const overload of make_product(std::array<R, N> &). | |
template<typename... Rs> | |
detail::multiplied< Rs... > | product (Rs &&...rgs) |
Lazy-multiply a given number of ranges by forming their cartesian product. | |
template<typename R > | |
detail::sliced< R > | slice (R &&rg, std::ptrdiff_t start_idx, std::ptrdiff_t end_idx) |
Lazy-slice a given range. | |
template<typename R > | |
detail::strided< R > | stride (R &&rg, std::ptrdiff_t stride) |
Lazy-stride through a given range. | |
template<typename R , typename F > | |
auto | transform (R &&rg, F lambda) |
Lazy-transform a given range by applying a unary callable object to every element of the original range. | |
template<typename... Rs> | |
detail::zipped< Rs... > | zip (Rs &&...rgs) |
Lazy-zip ranges together (similar to Python's zip). | |
detail::enumerated< R > enumerate | +( | +R && | rg | ) | ++ |
#include <itertools/enumerate.hpp>
Lazy-enumerate a given range (similar to Python's enumerate).
+Each element in the original range is assigned an index, starting from zero. This function returns an iterable lazy object (a detail::enumerated range), which iterates over tuples consisting of the index and the value of the dereferenced iterator of the original range:
+Output:
+See also std::ranges::views::enumerate.
+R | Range type. |
rg | Range to enumerate. |
Definition at line 172 of file enumerate.hpp.
+ +auto make_product | +( | +std::array< R, N > & | arr | ) | ++ |
#include <itertools/product.hpp>
Create a cartesian product range from an array of ranges.
+R | Range type. |
N | Number of ranges. |
arr | Array of ranges. |
Definition at line 268 of file product.hpp.
+ +auto make_product | +( | +std::array< R, N > const & | arr | ) | ++ |
#include <itertools/product.hpp>
Const overload of make_product(std::array<R, N> &).
+ +Definition at line 273 of file product.hpp.
+ +detail::multiplied< Rs... > product | +( | +Rs &&... | rgs | ) | ++ |
#include <itertools/product.hpp>
Lazy-multiply a given number of ranges by forming their cartesian product.
+An arbitrary number of ranges are multiplied together into a cartesian product range. They are traversed such that the last range is traversed the fastest (see the example below). The number of elements in a product range is equal to the product of the sizes of the given ranges. This function returns an iterable lazy object, which can be used in range-based for loops:
+Output:
+See also std::ranges::views::cartesian_product.
+Rs | Range types. |
rgs | Ranges to be used. |
Definition at line 258 of file product.hpp.
+ +detail::sliced< R > slice | +( | +R && | rg, | +
+ | + | std::ptrdiff_t | start_idx, | +
+ | + | std::ptrdiff_t | end_idx ) | +
#include <itertools/slice.hpp>
Lazy-slice a given range.
+Only the part of the given range between the start_idx
and the end_idx
is taken into account. If end_idx
is bigger than the size of the original range, the slice ends at the end of the original range. If end_idx
is smaller than start_idx
, the slice is empty. Note that the behaviour is undefined if start_idx
is smaller than zero. This function returns an iterable lazy object, which can be used in range-based for loops:
Output:
+R | Range type. |
rg | Range to be sliced. |
start_idx | Index where the slice starts. |
end_idx | Index of the first element past the end of the sliced range (excluded). |
detail::strided< R > stride | +( | +R && | rg, | +
+ | + | std::ptrdiff_t | stride ) | +
#include <itertools/stride.hpp>
Lazy-stride through a given range.
+Only every Nth element of the original range is taken into account. If the given stride (N) is <= 0, an exception is thrown. This function returns an iterable lazy object, which can be used in range-based for loops:
+Output:
+See also See also std::ranges::views::stride.
+R | Range type. |
rg | Original range. |
stride | Number of elements to skip when incrementing. |
Definition at line 180 of file stride.hpp.
+ +auto transform | +( | +R && | rg, | +
+ | + | F | lambda ) | +
#include <itertools/transform.hpp>
Lazy-transform a given range by applying a unary callable object to every element of the original range.
+The value type of the transformed range depends on the return type of the callable. This function returns an iterable lazy object (a detail::transformed range), which can be used in range-based for loops:
+Output:
+See also std::ranges::views::transform.
+R | Range type. |
F | Callable type. |
rg | Range to transform. |
lambda | Callable to be applied to the given range. |
Definition at line 191 of file transform.hpp.
+ +detail::zipped< Rs... > zip | +( | +Rs &&... | rgs | ) | ++ |
#include <itertools/zip.hpp>
Lazy-zip ranges together (similar to Python's zip).
+An arbitrary number of ranges are zipped together into a tuple. The zipped range will have as many elements as the shortest given range. This function returns an iterable lazy object, which can be used in range-based for loops:
+Output:
+See also std::ranges::views::zip.
+Rs | Range types. |
rgs | Ranges to zip. |
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
Range iterators are internally used by the library to iterate over Adapted ranges.
+In general, there should be no need for users to deal with range iterators directly. Instead, it is recommended to use range-based for loops, e.g.
vs. the traditional for loops, e.g.
+Classes | |
struct | enum_iter< Iter > |
Iterator for a detail::enumerated range. More... | |
struct | prod_iter< EndIters, Iters > |
Iterator for a detail::multiplied (cartesian product) range. More... | |
struct | stride_iter< Iter > |
Iterator for a detail::strided range. More... | |
struct | transform_iter< Iter, F, Value > |
Iterator for a detail::transformed range. More... | |
struct | zip_iter< Iters > |
Iterator for a detail::zipped range. More... | |
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
Utilities are mostly internal implementation details and should not concern everyday users.
+The only functions the might be intersting to some users are: chunk_range, make_vector_from_range and omp_chunk.
++Classes | |
struct | iterator_facade< Iter, Value, std::forward_iterator_tag, Reference, Difference > |
CRTP base class for various iterator types in itertools. More... | |
struct | sentinel_t< Iter > |
Generic sentinel type that can be used to mark the end of a range. More... | |
+Functions | |
std::pair< std::ptrdiff_t, std::ptrdiff_t > | chunk_range (std::ptrdiff_t first, std::ptrdiff_t last, long n_chunks, long rank) |
Given an integer range [first, last) , divide it as equally as possible into N chunks. | |
template<typename Iter1 , typename Iter2 > | |
std::iterator_traits< Iter1 >::difference_type | distance (Iter1 first, Iter2 last) |
Calculate the distance between two iterators. | |
template<typename Iter > | |
sentinel_t< Iter > | make_sentinel (Iter it) |
Create an itertools::sentinel_t from an iterator using template type deduction. | |
template<typename R > | |
auto | make_vector_from_range (R const &rg) |
Create a vector from a range. | |
template<typename R > | |
auto | omp_chunk (R &&rg) |
Distribute a range as evenly as possible across all OMP threads. | |
+
|
+ +inline | +
#include <itertools/utils.hpp>
Given an integer range [first, last)
, divide it as equally as possible into N chunks.
It is intended to divide a range among different processes. If the size of the range is not divisible by N without a remainder, i.e. r = (last - first) % N
, then the first r
chunks have one more element.
first | First value of the range. |
last | Last value of the range (excluded). |
n_chunks | Number of chunks to divide the range into. |
rank | Rank of the calling process. |
+
|
+ +inline | +
#include <itertools/utils.hpp>
Calculate the distance between two iterators.
+It is similar to std::distance, except that it can be used for two different iterator types, e.g. in case one of them is a const iterator.
+Iter1 | Iterator type #1. |
Iter2 | Iterator type #2. |
first | Iterator #1. |
last | Iterator #2. |
sentinel_t< Iter > make_sentinel | +( | +Iter | it | ) | ++ |
#include <itertools/sentinel.hpp>
Create an itertools::sentinel_t from an iterator using template type deduction.
+Iter | Iterator type. |
it | Iterator to be turned into an itertools::sentinel_t. |
Definition at line 50 of file sentinel.hpp.
+ +auto make_vector_from_range | +( | +R const & | rg | ) | ++ |
#include <itertools/utils.hpp>
Create a vector from a range.
+R | Range type. |
rg | Range. |
auto omp_chunk | +( | +R && | rg | ) | ++ |
#include <itertools/omp_chunk.hpp>
Distribute a range as evenly as possible across all OMP threads.
+See chunk_range(std::ptrdiff_t, std::ptrdiff_t, long, long) and slice(R &&, std::ptrdiff_t, std::ptrdiff_t) for more details.
+R | Range type. |
rg | Range to chunk. |
Definition at line 40 of file omp_chunk.hpp.
+ +
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
++This is the homepage of TRIQS/itertools 1.2.0. The source code can be found on GitHub.
+
itertools defines a small subset of the ranges and views from std::ranges. The main purpose of the library is to provide lazy ranges
Note that nearly all of the functionality (and much more) of itertools is also provided by std::ranges or Eric Niebler's range-v3 library. We therefore recommend to use one of those, if you have a choice.
+The Installation section tells you how to get the library and make it available on your system.
+Integration in C++ projects explains how to integrate itertools in your own C++ code.
+Then, you can start with the Examples section to get an overview of the library's features and how it compares with std::ranges
.
Furthermore, we provide a detailed reference API Documentation to answer your questions.
+If you experience any problem with the library, you can post an Issue on GitHub.
+
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
itertools is a header only library and installation is not necessary. However, it still supports the usual installation procedure using CMake.
+If you want to skip the installation step, you can go directly to Integration in C++ projects to see how you can integrate itertools into your own C++ project.
+++Note: To guarantee reproducibility in scientific calculations, we strongly recommend the use of a stable release version.
+
The dependencies of itertools are as follows:
+Download the source code of the latest stable version by cloning the TRIQS/itertools repository from GitHub:
+Create and move to a new directory where you will compile the code:
+In the build directory call cmake, including any additional custom CMake options (see below):
+Note that it is required to specify CMAKE_INSTALL_PREFIX
, otherwise CMake will stop with an error.
Compile the code, run the tests and install the application:
+Replace N
with the number of cores you want to use to build the library.
To use a particular version, go into the directory with the sources, and look at all available versions:
+Checkout the version of the code that you want:
+and follow steps 2 to 4 to compile the code.
+The compilation of itertools can be configured using CMake options
+Options | Syntax |
---|---|
Specify an installation path | -DCMAKE_INSTALL_PREFIX=path_to_install_dir |
Build in Debugging Mode | -DCMAKE_BUILD_TYPE=Debug |
Disable testing (not recommended) | -DBuild_Tests=OFF |
Build the documentation | -DBuild_Documentation=ON |
Build benchmarks | -DBuild_Benchs=ON |
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
itertools is a header only library. To use it in your own C++
code, you simply have to include the following header
and tell your compiler/build system where it can find the necessary files. In the following, we describe some common ways to achieve this (with special focus on CMake).
+If you use CMake to build your source code, it is recommended to fetch the source code directly from the Github repository using CMake's FetchContent module:
+Note that the above will also build goolgetest and the unit tests for itertools. To disable this, you can put set(Build_Tests OFF CACHE BOOL "" FORCE)
before fetching the content.
If you have already installed itertools on your system by following the instructions from the Installation page, you can also make use of CMake's find_package command. This has the advantage that you don't need to download anything, i.e. no internet connection is required.
+Let's assume that itertools has been installed to path_to_install_dir
. Then linking your project to itertools with CMake is as easy as
In case, CMake cannot find the package, you might have to tell it where to look for the itertools-config.cmake
file by setting the variable itertools_DIR
to path_to_install_dir/lib/cmake/itertools
or by sourcing the provided itertoolsvars.sh
before running CMake:
You can also integrate itertools into our CMake project by placing the entire source tree in a subdirectory and call add_subdirectory()
:
Here, it is assumed that the itertools source tree is in a subdirectory deps/itertools
relative to your CMakeLists.txt
file.
Since itertools is header-only, you can also simply copy the relevant files directly into our project. For example, you could place the c++/itertools
directory from the itertools source tree into the include path of your project. You can then build or compile it with any available method.
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
Please report all problems and bugs directly at the GitHub issues page. In order to make it easier for us to solve the issue please follow these guidelines:
+CMakeLists.txt
at the root of the application sources.cmake
and make
commands as well as the CMakeCache.txt
file which is in the build directory. Please include these outputs in a gist file referenced in the issue.Thanks!
+
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
#include <cstddef>
#include <iterator>
Provides a CRTP base class for various iterator types in itertools.
+ +Definition in file iterator_facade.hpp.
+Go to the source code of this file.
++Classes | |
struct | iterator_facade< Iter, Value, std::forward_iterator_tag, Reference, Difference > |
CRTP base class for various iterator types in itertools. More... | |
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+
#include "./enumerate.hpp"
#include "./product.hpp"
#include "./range.hpp"
#include "./slice.hpp"
#include "./stride.hpp"
#include "./transform.hpp"
#include "./zip.hpp"
Provides a small subset of the ranges and views from std::ranges.
+ +Definition in file itertools.hpp.
+
+ TRIQS/itertools 1.2.0
+
+ C++ range library
+ |
+