Range library for C++14/17/20, basis for C++20's std::ranges

Overview

range-v3

Range library for C++14/17/20. This code was the basis of a formal proposal to add range support to the C++ standard library. That proposal evolved through a Technical Specification, and finally into P0896R4 "The One Ranges Proposal" which was merged into the C++20 working drafts in November 2018.

About:

Ranges are an extension of the Standard Template Library that makes its iterators and algorithms more powerful by making them composable. Unlike other range-like solutions which seek to do away with iterators, in range-v3 ranges are an abstration layer on top of iterators.

Range-v3 is built on three pillars: Views, Actions, and Algorithms. The algorithms are the same as those with which you are already familiar in the STL, except that in range-v3 all the algorithms have overloads that take ranges in addition to the overloads that take iterators. Views are composable adaptations of ranges where the adaptation happens lazily as the view is iterated. And an action is an eager application of an algorithm to a container that mutates the container in-place and returns it for further processing.

Views and actions use the pipe syntax (e.g., rng | adapt1 | adapt2 | ...) so your code is terse and readable from left to right.

Documentation:

Check out the (woefully incomplete) documentation here.

Other resources (mind the dates, the library probably has changed since then):

License:

Most of the source code in this project are mine, and those are under the Boost Software License. Parts are taken from Alex Stepanov's Elements of Programming, Howard Hinnant's libc++, and from the SGI STL. Please see the attached LICENSE file and the CREDITS file for the licensing and acknowledgments.

Supported Compilers

The code is known to work on the following compilers:

  • clang 5.0 (or later)
  • GCC 6.5 (or later)
  • Clang/LLVM 6 (or later) on Windows (older versions may work - we haven't tested.)
  • Visual Studio 2019 (or later) on Windows, with some caveats due to range-v3's strict conformance requirements:
    • range-v3 needs /permissive- and either /std:c++latest or /std:c++17

Development Status: This code is fairly stable, well-tested, and suitable for casual use, although currently lacking documentation. In general, no promise is made about support or long-term stability. This code will evolve without regard to backwards compatibility.

A notable exception is anything found within the ranges::cpp20 namespace. Those components will change rarely or (preferably) never at all.

Build status

  • on GitHub Actions: GitHub Actions Status

Building range-v3 - Using vcpkg

You can download and install range-v3 using the vcpkg dependency manager:

git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install range-v3

The range-v3 port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please create an issue or pull request on the vcpkg repository.

Building range-v3 - Using Conan

You can download and install range-v3 using the Conan dependency manager.

Setup your CMakeLists.txt (see Conan documentation on how to use MSBuild, Meson and others):

project(myproject CXX)

add_executable(${PROJECT_NAME} main.cpp)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) # Include Conan-generated file
conan_basic_setup(TARGETS) # Introduce Conan-generated targets

target_link_libraries(${PROJECT_NAME} CONAN_PKG::range-v3)

Create conanfile.txt in your source dir:

[requires]
range-v3/0.10.0

[generators]
cmake

Install and run conan, then build your project as always:

pip install conan
mkdir build
cd build
conan install ../ --build=missing
cmake ../
cmake --build .

Building range-v3 - Using build2

You can use build2, a dependency manager and a build-system combined, to use range-v3 (or work on it):

Currently this package is available in these package repositories:

Usage:

For example, to make your build2 project depend on range-v3:

  • Add one of the repositories to your configurations, or in your repositories.manifest, if not already there; for example:
    :
    role: prerequisite
    location: https://pkg.cppget.org/1/alpha # v0.11.0 is there.
    
  • Add this package as a dependency to your manifest file (example for v0.11.x):
    depends: range-v3 ~0.11.0
    
  • Import the target and use it as a prerequisite to your own target using range-v3 in the appropriate buildfile:
    import range_v3 = range-v3%lib{range-v3}
    
    lib{mylib} : cxx{**} ... $range_v3
    

Then just build your project as usual (with b or bdep update), build2 will figure out the rest.

For build2 newcomers or to get more details and use cases, you can read this document and the build2 toolchain introduction.

Say Thanks!

I do this work because I love it and because I love C++ and want it to be as excellent as I know it can be. If you like my work and are looking for a way to say thank you, you can leave a supportive comment on my blog. Or you could leave me some kudos on my Open Hub range-v3 contribution page. Just click the Give Kudos button here.

Issues
  • `const`-ness of view operations

    `const`-ness of view operations

    Containers

    Containers in C++ may have both const and non-const overloads of begin. They differ only in their return types: non-const begin returns a mutable iterator, and const begin a constant iterator. Neither overload changes the bits of the container representation or modifies the semantic value of the container object. Two overloads exist so that it is necessary to establish a non-const access path to the container object in order to obtain a mutable iterator. end is the same. size is always const because it provides no way to modify the container's content.

    Views

    Views in range-v3 may have both const and non-const overloads of begin/end/size (herein termed "operations"). Views have pointer semantics - a view is essentially a pointer to a sequence of elements - so mutability of the elements viewed is orthogonal to mutability of the view object itself. The const distinction here has no relation to that of containers. Non-const operations do not modify the semantic objects being viewed, nor do they "swing the pointer" so that the same view designates different semantic objects. Non-const operations mutate internal state that does not contribute to the semantic value of the view; the const-ness here is purely bitwise.

    The const-ness model used by views makes view composition painful. You can always provide the non-const overloads, but const overloads are preferred when achievable. So a composer, e.g.:

    template<typename View>
    class wrap_view : view_facade<wrap_view<View>>
    {
        View base_;
    public:
        wrap_view() = default;
        wrap_view(View v)
        : base_(std::move(v))
        {}
        // ...
    };
    

    ends up providing two definitions of each operation: one const that's constrained to require const operations over the underlying view(s):

        // We need the dependent type V so that range_iterator_t<V const> doesn't hard
        // error when View has no const begin operation (or: use C++14 deduced return type).
        template <typename V = View, CONCEPT_REQUIRES_(Range<View const>())>
        range_iterator_t<V const> begin() const
        { return ranges::begin(base_); }
    

    and one mutable that's constrained to only be available when the const version isn't:

        CONCEPT_REQUIRES(!Range<View const>())
        range_iterator_t<View> begin()
        { return ranges::begin(base_); }
    

    Ranges

    I'm concerned that the differing const distinctions for containers and views don't mesh well into a consistent notion of what const means for operations on general ranges. I see a potential for latent bugs where a programmer accustomed to the fact that calling begin/end on mutable containers is threadsafe calls begin/end on mutable ranges without realizing there are sharp corners here.

    The only mutating operation on pointers is assignment. If views are supposed to be range-pointers, perhaps assignment should be the only mutating operation? We (I) need to investigate an alternative model where view operations are always const and perform internal synchronization if needed.

    opened by CaseyCarter 81
  • [cmake/travis] refactor/improve CMake; add MSan/LSan builds in travis

    [cmake/travis] refactor/improve CMake; add MSan/LSan builds in travis

    • Adds MemorySanitizer and LeakSanitizer (under ASan) in travis:

      • Builds libc++ with MemorySanitizer and AddressSanitizer as required.
      • Enables the leak sanitizer on AddressSanitizer builds under Linux.
      • Enables the unsigned-integer overflow check in the UndefinedBehaviorSanitizer:
        • Avoids overflow in view.unique tests (not a bug).
        • Add RANGES_INTENDED_MODULO_ARITHMETIC macro to explicitly annotate when modulo arithmetic is intended.
        • Explicitly annotates those parts of range-v3 in which modulo arithmetic is intended (mostly in utility/random.hpp).
    • Refactor the root CMakeLists.txt into:

      • cmake/readme.md: brief explanation of what goes where.
      • cmake/ranges_options.cmake: library configuration options.
      • cmake/ranges_env.cmake: detects environment (os, compiler, build type...).
      • cmake/ranges_flags.cmake: sets up supported compiler flags.
    • AppVeyor and Clang/C2 (by @CaseyCarter):

      • Add cmake to PATH in appveyor.yml.
      • Disable -fstruct-vtable-pointers on Clang/C2.
    • Add RANGES_NATIVE option (defaults to On) to allow disabling -march/mtune=native independently of the build-type.

    • Disables std::auto_ptr in boost (not available in C++1z).

    • Add travis build bots for clang-4.0 in C++11 and C++14.

    • Tests clang versions with the corresponding libc++ version (they were always tested with libc++ trunk).

    Closes #333: the ASAN errors reported there cannot be reproduced anymore. Closes #451: -Wnoexcept should be part of -Weverything. Closes #640: clang versions are tested with appropriate libc++ version.

    Thanks @CaseyCarter for the comments, help, and all the Clang/C2 and AppVeyor fixes.

    opened by gnzlbg 42
  • view::cycle

    view::cycle

    Turns a finite ForwardRange into an infinite range that cycles on itself.

    Example

    auto il = {0, 1, 2};
    RANGES_FOR(auto i, il | view::cycle) { std::cout << i << " "; }
    

    prints "0 1 2 0 1 2 0 1 2 0 1 2...".

    Notes on the design

    This designs chooses to make two iterators compare equal only if they point to the same element of the sequence within the same cycle. Example: in the sequence above both iterators begin and begin + 3 point to the same element (0); since they are "in different cycles" they are not equal.

    The rationale is that this allows iterating from [begin, begin + M) where M is larger than the number of elements in the sequence.

    TODO

    • The implementation of cycled_view<Rng>::cursor<IsConst>::advance is pretty ugly.
    • The implementation of cycled_view<Rng>::cursor can be optimized for RandomAccessRanges where the iterator can be obtained from the position in O(1).
    opened by gnzlbg 42
  • Why is filter deprecated?

    Why is filter deprecated?

    I find both filter and remove_if useful. Replacing filter(pred) with remove_if(not(pred)) makes IMO the code less readable. The intent is just harder to understand due to the double negation: do something on the elements that are not the elements for which the predicate is not true (my brain melts).

    opened by gnzlbg 30
  • Proposal: enumerated range

    Proposal: enumerated range

    I find myself doing the following quite often:

    for (const auto& [i, e]: rsv::zip(rsv::iota(0, es.size()), es)) { /* use i, e */ }
    

    This to my mind is more explicit, and leaves less room for mistakes, than:

    for (auto i = 0; i < es.size(); ++i) { /* use i, es[i] */ }
    

    If this idiom is a bad idea, I would appreciate being told why. If not, I think this would be a good candidate for addition to the library, because it is frequently the case that one wants to know the index of the item one is iterating over.

    In my code, I call this enumerated(es), but I'm not particularly attached to this name.

    enhancement 
    opened by seertaak 29
  • Compilation failure because GCC _Safe_iterator meets SizedIteratorRange concept

    Compilation failure because GCC _Safe_iterator meets SizedIteratorRange concept

    I'm getting a compilation failure that I think stems from a (GCC _GLIBCXX_DEBUG) bidirectional iterator meeting the SizedIteratorRange concept and then failing when range-v3 actually uses an expression like itr_a - itr_b.

    I'm guessing the troublesome subtlety may be: the iterator is actually a GCC _Safe_iterator, which does provide an operator-() but which just implements this by passing through to the wrapped std::list iterator that doesn't provide an operator-(). Hence I'm guessing the concepts::same_type(s - i, i - s) line in the SizedIteratorRange concept is checking that the iterator's operator-() exists and has a valid return type but isn't checking that a call to that expression is actually valid. Hence SizedIteratorRange isn't spotting that itr_a - itr_b isn't a valid expression and so doesn't get itself SFINAE-rejected as it should.

    Some illustrative code:

    #define _GLIBCXX_DEBUG
    #define RANGES_NO_STD_FORWARD_DECLARATIONS
    
    #include <iostream>
    #include <list>
    #include <type_traits>
    
    #include <range/v3/all.hpp>
    
    int main() {
        // Background context:
        // Under _GLIBCXX_DEBUG, list returns a list iterator wrapped in a _Safe_iterator
        // whose iterator_category is bidirectional_iterator_tag
        using my_range_type  = std::list< int >;
        using my_iter_type   = decltype( std::begin( std::declval< my_range_type >() ) );
        static_assert(
            std::is_same<
                std::iterator_traits<my_iter_type>::iterator_category,
                std::bidirectional_iterator_tag
            >::value,
            ""
        );
    
        // Background context:
        // range-v3 identifies the _Safe_iterator<...> as SizedIteratorRange
        using rv3_iterator_t = ranges::range_iterator_t< my_range_type >;
        using rv3_sentinel_t = ranges::range_sentinel_t< my_range_type >;
        using rv3_sirc_t     = ranges::sized_iterator_range_concept<rv3_iterator_t,
                                                                    rv3_sentinel_t>;
        ranges::concepts::SizedIteratorRange * my_ptr = rv3_sirc_t();
    
        //  **** PROBLEM HERE *****
        // Fails to compile the '...::take( 3 );' line.
        // I think that's because range-v3 treats _Safe_iterator<...> as a
        // SizedIteratorRange iterator but then cannot subtract one from another
        // (because that's not supported by the underlying list iterator)
        const my_range_type my_values = { 1, 2, 3, 4 };
        const auto my_first_values = my_values | ranges::v3::view::take( 3 );
        std::cerr << *ranges::max_element( my_first_values ) << "\n";
    
        return 0;
    }
    

    Compile command:

    g++ -std=c++11 -isystem range-v3/include -ftemplate-backtrace-limit=0 rv3_safe_iter_prob.cpp
    

    (also works with -std=c++14; -ftemplate-backtrace-limit=0 avoids clipped messages)

    opened by tonyelewis 28
  • Find a better name for iterator_range

    Find a better name for iterator_range

    Especially when dealing with old/current interfaces you sometimes have a pair of begin/end iterators you have to deal with. It would be great if I could e.g. view::all_between(it, it_end) | view::join | ...

    Does something like this exist and I just overlooked it? If not, do you agree, it would be nice to have? I could look into it and maybe create a PR...

    opened by h-2 26
  • Uniform namespace conventions between Meta and Range/utility/Meta

    Uniform namespace conventions between Meta and Range/utility/Meta

    I'm trying to make Range work bootstrapping Meta into it first, instead of having (maintaining) both copies of the same library. My idea is to make this change least intrusive possible. Given the current meta.hpp file in range, what I'm doing is:

    #if defined(BIICODE)
    #include <meta/meta.hpp>
    #else
    #include <type_traits>
    #include <initializer_list>
    #include <range/v3/utility/nullptr_v.hpp>
    #include <range/v3/utility/static_const.hpp>
    ...
    

    The dependency works perfectly, but I'm not able to compile since Meta and Range are using different namespaces to declare/define Meta features. Relying on sorcery like #include inside a nested namespace is not a solution for me, neither for you I guess (Ignoring that trick would potentially generate name issues with STL things etc).

    Maybe we can study the effort neccesary to unify both naming conventions.

    opened by Manu343726 24
  • Add view::shared

    Add view::shared

    Description: view::shared was designed to allow the construction of temporary containers in the middle of the range pipeline (such as inside view::for_each or view::transform). Such temporary containers can be afterwards used in the remaining part of the pipeline, without the danger of dangling references. view::shared allows elegant constructions, which would be otherwise very difficult to express and the code readability would be significantly degraded (see examples at the end of this description).

    Internally, view::shared stores only std::shared_ptr to the underlying range, and therefore construction, destruction, copying and moving of view::shared are still O(1)-time operations, except for the last destruction, which can take up to O(N) time. The linear complexity of the last destruction, however, can be amortized with the time needed to construct the underlying container.

    It can be constructed:

    • from an rvalue reference of a range
    • from std::shared_ptr of a range
    • as a function
    • as a range pipeline element

    Example 1: Apply a transformation function returning a vector, to a range of integers, and flatten the result.

    std::vector<int> foo(int a);
    auto rng =
        view::iota(1)
      | view::transform(foo)
      | view::transform(view::shared)
      | view::join;
    

    Example 2: Build a range which repeats the numbers from a pre-specified vector, but in each epoch, the numbers are randomly shuffled (as is usual e.g., for the training data in machine learning).

    std::vector<int> base{5, 1, 8};
    auto rng =
        view::repeat(base)
      | view::for_each([](std::vector<int> tmp) {
            return std::move(tmp)
                 | action::shuffle(gen)
                 | view::shared;
        });
    

    Stand-alone views: Naturally, view::shared can be used to encapsulate the initial data structure inside a view without bothering with the structure's scope. Therefore, it allows the creation of stand-alone views inside of functions:

    auto build_view()
    {
        std::vector<int> base{5, 1, 8};
        return std::move(base) | view::shared | ...
    }
    
    opened by FloopCZ 23
  • Taking distance() of const ref to view::remove_if fails to compile

    Taking distance() of const ref to view::remove_if fails to compile

    Taking the distance() of a const-lvalue-reference to a view::remove_if fails to compile under both GCC and Clang because it attempts to calculate a type using ranges::range_difference_t<T>, which fails as illustrated in this example:

    #include <range/v3/all.hpp>
    
    int main() {
        int rg[] = { 1, 2, 3, 4, 5 };
    
        // This     const view::tail      is fine
        const auto const_tail_view        = rg | ranges::view::tail;
        using      const_tail_view_diff_t = ranges::range_difference_t< decltype( const_tail_view ) >;
    
        // This non-const view::remove_if is fine
              auto even_view              = rg | ranges::view::remove_if( [] (const int &i) { return ( i % 2 == 0 ); } );
        using      even_view_diff_t       = ranges::range_difference_t< decltype( even_view ) >;
    
        // This     const view::remove_if fails to compile
        const auto const_even_view        = rg | ranges::view::remove_if( [] (const int &i) { return ( i % 2 == 0 ); } );
        using      const_even_view_diff_t = ranges::range_difference_t< decltype( const_even_view ) >;
    
        return 0;
    }
    

    My understanding is that this attempts to compute the type of begin(std::declval<T&>()), which leads to a failed instantiation of the begin_fn::operator()() template, which then fails because neither private impl() function can be used.

    I've found that this problem occurs with both view::remove_if and view::drop_while but not with:

    • view::adjacent_remove_if
    • view::chunk
    • view::delimit
    • view::drop
    • view::replace
    • view::reverse
    • view::slice
    • view::stride
    • view::tail
    • view::take
    • view::take
    • view::take_exactly
    • view::take_while
    opened by tonyelewis 22
  • fix missing includes forever

    fix missing includes forever

    All kudos go to Louis Dione for writing the CMake scripts of Boost.Hana.

    This just adapts his scripts for range-v3; all mistakes introduced are only mine.

    • fix missing includes caught by the tests.
    • replace # warning with #pragma message because -Werror, -Wpedantic complains that # warning is a language extension (this prevents some new tests from compiling).

    Closes #182 .

    opened by gnzlbg 22
  • Unused and broken test files

    Unused and broken test files

    While preparing the build2 package for range-v3 v0.12.0 I discovered that test/algorithm/partition_move.cpp is not referred anywhere in CMake files. It also attempts to include a header that does not exist: #include <range/v3/algorithm/partition_move.hpp>

    It is not clear to me if this file

    • should be simply removed, or
    • should be added to the CMake files, and if so there is a header missing (it's not in current version)

    I also found copy_n.cpp and fill_n.cpp as not being referred by CMake files either and having their code not compiling because of errors about accessing inexistent members of this library's types (which suggests they are just not in sync with the current headers).


    For context, build2 being a build-system in addition to a package manager, we re-defined the build of the library and its tests by following (as best as we can) the instructions from the CMakeFiles.txt files. However we use globing patterns as much as we can instead of manually listing files (which makes our build files quite short). Currently the rule will take any cpp file in test/** and generate an executable named the same way as the file, which is the pattern we observe in the CMakeFiles.txt for tests and which allow us to not have much to change in build2 files when packaging a new version (new files are automatically added, removed files are automatically removed). However this means that files which are not listed in CMakeFiles.txt but that do exist, like partition_move.cpp refered here, will be built by build2 and this currently lead to the build failing because of the missing header.

    For now I'm adding some exclusion in the build2 script to simply not compile these files, so I can publish v0.12.0, so this is not preventing me from working.

    opened by Klaim 0
  • Partial implementation of P2325

    Partial implementation of P2325

    Fixes #1707.

    This is a partial implementation, in that I'm removing the requirements of default construction from the concepts and removing the partially-formed default constructors that I removed in that paper. I didn't go through and properly constrain the default constructors of all the adaptors (some might be okay, others not, it's kind of annoying that T member; for non-default-constructible T does delete the default constructor, but T member = T(); does not... unless you're gcc) nor try to optimize the adaptors to use a new copyable_box instead of a semiregular_box.

    This also isn't thoroughly tested, but because ref_view is no longer default constructible and lots of adaptor tests do use it, that should have exposed some issues if they existed.

    opened by brevzin 1
  • Relax indirect callable constraints

    Relax indirect callable constraints

    Introduces a new indirect-callable-trait called indirect_value_t to ensure correct value-type computation for algorithms that take projections. Instead of forming a reference to the invoke-result of the projection, it now computes the invoke-result of the projection with a reference to the iterators value-type.

    Projections are discriminated from iterators by the existence of a nested typedef indirect_value_type.

    More details here: https://jehelset.gitlab.io/cpp/relaxing-ranges-just-a-smidge/

    I was a bit unsure what was the idiomatic way to check for the existence of a nested member-type in ranges-v3.

    opened by jehelset 0
  • Cannot easily use ref-qualified member functions as projections

    Cannot easily use ref-qualified member functions as projections

    This call fails to compile:

    const auto it{ranges::find(values, stringToFind, &Value::value)};
    

    with:

    error: no match for call to '(const ranges::find_fn) (const std::vector<Value>&, const std::string&, <unresolved overloaded function type>)'
    
    ...
    
    note:   couldn't deduce template parameter 'V'
    

    when member function value has ref-qualified overloads:

    [[nodiscard]] std::string value() &;
    [[nodiscard]] const std::string &value() const& noexcept;
    [[nodiscard]] std::string &&value() && noexcept;
    

    I can make it work by using lambda as projection, or static_cast'ing member function to specific signature, but these solutions are too verbose and just loses the beauty of projections...

    Full example here: https://godbolt.org/z/ddj5qE1EE

    I guess it's "wontfix", but maybe there's is some magic template trickery to select best overload..?

    bug 
    opened by Talkless 10
Releases(0.12.0)
  • 0.12.0(Jun 21, 2022)

    Released: June 21, 2022

    IMPORTANT: This release deprecates views::group_by which was an endless source of confusion. group_by is replaced with views::chunk_by (which, beware, has subtly different semantics, see below.)

    Changes:

    • NEW: views::chunk_by which, like the old views::group_by it replaces, splits a range into a range-of-ranges, where adjacent elements satisfy a binary predicate (#1648). [Note: Whereas views::group_by evaluated the predicate between the current element and the first element in the chunk, views::chunk_by evaluates the predicate between adjacent elements. -- end note]
    • NEW: constexpr all the algorithms that are constexpr in C++20's std::ranges (#1683).
    • NEW: Fold algorithms from P2322 (#1628), (#1668).
    • NEW: ranges::unformatted_ostream_iterator (#1586).
    • NEW: Support for the build2 build system (#1562).
    • Implement P2328: relax the constraint on ranges::join_view to support joining ranges of prvalue non-view ranges (#1655).
    • Improved algorithm for ranges::linear_distribute (#1679).
    • Renamed safe_subrange_t to borrowed_subrange_t (#1542).
    • Extend ranges::to to support conversion to container-of-containers (#1553).
    • views::enumerate can be a borrowed_view (#1571).
    • ranges::upper_bound works in the presence of overloaded operator& (#1632).
    • Input iterators are no longer required to be default-constructible (#1652).

    Bugs fixed:

    • ranges::to<std::map>(v) does not work (#1700)
    • ranges::reverse_iterator has the wrong value_type when reversing a proxy range (#1670).
    • A post-increment of a ranges::counted_iterator wrapping an input iterator with a void-returning post-increment operator isn't incrementing the count (#1664).
    • Bad assert in views::drop_last (#1599).
    • Read of uninitialized bool in views::cache1 (#1610).
    • ranges::unstable_remove_if calls predicate on same element twice (#1629).
    • ranges::on(f,g)(x...) should be f(g(x)...) instead of f(g(x...)) (#1661).
    • Broken qualification of cmake targets (#1557).
    • Various portability and documentation fixes.

    Credits: I would like to thank the following people who contributed to this release (in no particular order): Barry Revzin, @dvirtz, Gonzalo Brito, Johel Ernesto Guerrero Peña, Joël Lamotte, Doug Roeper, Facundo Tuesca, Vitaly Zaitsev, @23rd, @furkanusta, Jonathan Haigh, @SmorkalovG, @marehr, Matt Beardsley, Chris Glover, Louis Dionne, Jin Shang (@js8544), Hui Xie, @huixie90, Robert Maynard, Silver Zachara, @sergegers, Théo DELRIEU, @LesnyRumcajs, Yehezkel Bernat, Maciej Patro, Klemens Nanni, Thomas Madlener, and Jason Merrill.

    :tada: Special thanks to Barry Revzin for stepping up to be part-time co-maintainer of range-v3. :tada:

    Source code(tar.gz)
    Source code(zip)
  • 0.11.0(Aug 6, 2020)

    Released: August 6, 2020

    IMPORTANT: This release removes the heuristic that tries to guess whether a range type is a "view" (lightweight, non-owning range), in accordance with the C++20. This is a potentially source-breaking change. Code that previously used an rvalue range as the start of a pipeline could stop compiling if the range library is not explicitly told that that range type is a view. To override the new default, please specialize the ranges::enable_view<R> Boolean variable template.

    IMPORTANT: This release removes the implicit conversion from views to containers. To construct a container from an arbitrary range, you must now explicitly use ranges::to. For example, the following code no longer works:

    std::vector<int> is = ranges::views::ints(0, 10); // ERROR: no conversion
    

    Instead, please write this as:

    auto is = ranges::views::ints(0, 10) | ranges::to<std::vector>; // OK
    

    ranges::to lives in header <range/v3/range/conversion.hpp>

    IMPORTANT: This release drops support for llvm-3.9.

    Changes:

    • NEW: A new concepts portability layer that short-circuits atomic constraints in requires clauses for better compile times when emulating concepts.
    • NEW: Restored support for MSVC in /std:c++17 mode, and for MSVC's default preprocessor.
    • Remove the implicit conversion from views to containers.
    • Rename the following entities to be consistent with C++20's std::ranges support:
      • safe_range<R> -> borrowed_range<R>
      • enable_safe_range<R> -> enable_borrowed_range<R>
      • safe_iterator_t<R> -> borrowed_iterator_t<R>
      • safe_subrange_t<R> -> borrowed_subrange_t<R>
      • readable_traits<I> -> indirectly_readable_traits<I>
      • readable<I> -> indirectly_readable<I>
      • writable<I> -> indirectly_writable<I>
    • Added the following to the ranges::cpp20 namespace:
      • Algorithm for_each_n
      • Algorithm sample
      • Class view_base
      • Alias views::all_t
    • Type __int128 is recognized as "integer-like".
    • Adds concepts three_way_comparable[_with] when <=> is supported.
    • Adds concepts partially_ordered[_with].
    • Better conformance with C++20's use of the boolean-testable concept.
    • Support C++20 coroutines.
    • Honor CMake's CMAKE_CXX_STANDARD variable.
    • A fix for the cardinality of views::zip[_with] (#1486).
    • Add view_interface::data() member function.
    • Add necessary specializations for std::basic_common_reference and std::common_type.
    • Numerous workarounds for MSVC.
    • Various CMake fixes and improvements.
    • drop_while_view is not a sized_range.
    • Added support for Wind River Systems.
    • Bug fixes to views::group_by (#1393).
    • common_[reference|type] of common_[tuple|pair] now yields a common_[tuple|pair] instead of a std::[tuple|pair] (#1422).
    • Avoid UB when currying an lvalue in some views and actions (#1320).

    Credits: I would like to thank the following people who contributed to this release (in no particular order): Christopher Di Bella, @marehr, Casey Carter, Dvir Yitzchaki, Justin Riddell, Johel Ernesto Guerrero Peña, Barry Revzin, Kamlesh Kumar, and Vincas Dargis.

    Source code(tar.gz)
    Source code(zip)
  • 0.10.0(Dec 7, 2019)

    Released: Dec 6, 2019.

    IMPORTANT: Before upgrading, please note that several older compiler versions and build configurations are no longer supported! In particular, MSVC now needs /std:c++latest.

    ALSO: When taking a dependency on the range-v3, meta, or concepts libraries via CMake, please now use the namespace qualified target names:

    • range-v3::range-v3
    • range-v3::meta
    • range-v3::concepts

    Changes:

    • NEW: Rewritten concepts portability layer with simpler macros for better diagnostics.
    • NEW: The views::cache1 view caches the most recent value in the range. This can help avoid reevaluation of transformations in complex view pipelines.
    • NEW: ranges::contains algorithm.
    • NEW: enable_safe_range trait for opting in to the forwarding-range concept. These are ranges whose iterators remain valid even after the range itself has been destroyed; e.g., std::string_view and ranges::subrange.
    • The readable concept has changed such that types that are not indirectly readable with operator* (_e.g., std::optional) no longer satisfy that concept.
    • Using views::join to join a range of xvalue ranges works again.
    • The following range access primitives no longer accept temporary containers (i.e., they refuse to return references known to be dangling):
      • range::front
      • range::back
      • range::at
      • range::index
    • views::concat with a single argument now simply returns its argument.
    • ranges::ostream_iterator<T> now coerces arguments to T before inserting them into the wrapped ostream.
    • Smaller iterators for views::transform and views::take_while.
    • actions::split and actions::split_when now support partial application and pipelining (#1085).
    • views::group_by and its iterator both get a .base() member to access the underlying range and iterator, respectively.
    • Improved diagnostics with clang.
    • Assorted bug fixes and compiler work-arounds: #284, #491, #499, #871, #1022, #1043, #1081, #1085, #1101, #1116, #1296, #1305, and #1335.

    Many thanks to GitHub users @CaseyCarter, @morinmorin, @h-2, @MichaelWJung, @johelegp, @marehr, @alkino, @xuning97, @BRevzin, and @mpusz for their contributions.

    Source code(tar.gz)
    Source code(zip)
  • 0.9.0(Aug 25, 2019)

    Released: Aug 26, 2019.

    Bring many interfaces into sync with the C++20 draft.

    • NEW: An improved concepts portability layer with macros that use C++20 concepts when the compiler supports them.

    • NEW: An improved directory structure that keeps disjoint parts of the library -- iterators, ranges, algorithms, actions, views, functional programming support, and general utilities -- physically separate.

    • NEW: A RANGES_DEEP_STL_INTEGRATION configuration option that makes your STL implementation default to structural conformance to infer iterator category, as in C++20. Applies to libc++, libstdc++, and MSVC's Standard Library.

    • NEW: A ranges::cpp20 namespace that contains all the functionality of C++20's std::ranges namespace.

    • All concept names have been given standard_case (renamed from PascalCase) and have been harmonized with the C++20 draft.

    • The following range access customization points no longer accept rvalue ranges by default:

      • ranges::begin
      • ranges::end
      • ranges::rbegin
      • ranges::rend
      • ranges::cbegin
      • ranges::cend
      • ranges::crbegin
      • ranges::crend
      • ranges::data
      • ranges::cdata
    • Iterators may specify an iterator_concept type alias in addition to iterator_category -- either as a nested type or as a member of a std::iterator_traits specialization -- to denote conformance to the C++20 iterator concepts as distinct from the C++98 iterator requirements. (See P1037 "Deep Integration of the Ranges TS" for more information.)

    • The ranges::value_type trait has been renamed to readable_traits.

    • The ranges::difference_type trait has been renamed to incrementable_traits.

    • The ranges::iterator_category trait has been deprecated. Specialize std::iterator_traits to non-intrusively specify an iterator's category and (optionally) concept.

    • Rename the ranges::view namespace to ranges::views and ranges::action to ranges::actions (with deprecated namespace aliases for migration).

    • Rename view::bounded to views::common.

    • Rename unreachable to unreachable_sentinel_t.

    • Change dangling from a class template that wraps an iterator to a class that acts as a placeholder for an iterator that would otherwise dangle.

    • Implement C++20's subrange as a view that wraps an iterator/sentinel pair; deprecate iterator_range.

    • Deprecate implicit conversion from view types to containers; rename ranges::to_ to ranges::to and extend it to support converting a range-of-ranges to a container-of-containers.

    • Deprecate the ranges::v3 inline versioning namespace.

    • The following views have had minor changes to bring them into conformance with the C++20 working draft:

      • join_view
      • single_view
      • empty_view
      • split_view
      • reverse_view
      • all_view
      • take_view
      • iota_view

      `iota_view`, in particular, is given a user-defined `difference_type` that avoids integer overflow.

    • New names for the iterator and range type aliases:

      | Old Name | New Name | |-------------------------------|-----------------------------| | value_type_t | iter_value_t | | reference_t | iter_reference_t | | difference_type_t | iter_difference_t | | size_type_t | deprecated | | rvalue_reference_t | iter_rvalue_reference_t | | range_value_type_t | range_value_t | | range_difference_type_t | range_difference_t | | range_size_type_t | range_size_t |

    Source code(tar.gz)
    Source code(zip)
  • 0.5.0(Apr 30, 2019)

    • NEW: MSVC support, from @CaseyCarter :tada: (See the docs for the list of supported compilers.)
    • NEW: view::enumerate, from @MikeGitb
    • NEW: view::addressof, from @tower120
    • NEW: unstable_remove_if algorithm and action, from @tower120
    • NEW: adjacent_remove_if algorithm and action, from @tower120
    • NEW: ostream_joiner, from @sv1990
    • view::drop_while and view::take_while get projection support, from @mrpi
    • view::filter and view::remove_if get projection support, from @mrpi
    • view::unique accepts optional comparison operator, from @tete17
    • action::slice supports sliding from the end, from @tete17
    • Support coroutines on MSVC, from @CaseyCarter
    • Faster view::generate_n, from GitHub user @tower120
    • Improved aligned new detection for libc++ on iOS, from @mtak-
    • Various CMake improvements, from @johelegp
    • view_adaptor supports basic_iterator-style mixins, from @tower120
    • Fix ranges::advance for random-access iterators for n==0, from @tower120
    • Bugs fixed: #755, #759, #942, #946, #952, #975, #978, #986, #996, #1041, #1047, #1088, #1094, #1107, #1129
    Source code(tar.gz)
    Source code(zip)
  • 0.4.0(Oct 18, 2018)

    0.4.0 Oct 18, 2018

    • Minor interface-breaking changes:
      • single_view returns by const & (see #817).
      • reverse_view of a non-Sized, non-Bounded RandomAccess range (eg., a null-terminated string) no longer satisfies SizedRange.
      • The generate and generate_n views now return the generated values by xvalue reference (T &&) to the value cached within the view (see #905).
      • Views no longer prefer returning constant iterators when they can; some views have different constant and mutable iterators.
    • Enhancements:
      • Views can successfully adapt other views that have different constant and mutable iterators.
      • The single, empty, and reverse views are much closer to the versions as specified in P0896.
    • Bug fixes:
      • "single_view should not copy the value" #817.
      • "Calling back() on strided range does not return the correct last value in range" #901.
      • "generate(foo) | take(n) calls foo n+1 times" #819.
      • "generate seems broken with move-only return types" #905.
      • "Unexpected behavior in generate with return by reference" #807.
      • "Inconsistent behaviour of ranges::distance with ranges::view::zip using infinite views." #783.
      • "Infinite loop when using ranges::view::cycle with an infinite range" #780.
      • "Composing ranges::view::cycle with ranges::view::slice" #778.
      • "cartesian_product view, now with moar bugs." #919.
    Source code(tar.gz)
    Source code(zip)
  • 0.3.7(Sep 20, 2018)

    0.3.7 Sept 19, 2018

    • Improved support for clang-cl (thanks to @CaseyCarter).
    • Fix for any_view<T, category::sized | category::input> (see #869).
    • Fix iter_move of a ranges::reverse_iterator (see #888).
    • Fix move_sentinel comparisons (see #889).
    • Avoid ambiguity created by boost::advance and std::advance (see #893).
    Source code(tar.gz)
    Source code(zip)
  • 0.3.6(May 15, 2018)

    • 0.3.6 May 15, 2018
      • NEW: view::exclusive_scan (thanks to GitHub user @mitsutaka-takeda).
      • All views get non-const overloads of .empty() and .size() (see ericniebler/stl2#793).
      • Upgrade Conan support for conan 1.0.
      • subspan interface tweaks.
      • Fix bug in view::split (see this stackoverflow question).
      • Fix bug in view::stride (see ericniebler/stl2#805).
      • Fix const-correctness problem in view::chunk (see this stackoverflow question).
      • Replace uses of ranges::result_of with ranges::invoke_result.
      • Fix potential buffer overrun of view::drop over RandomAccessRanges.
      • Lots of view::cartesian_product fixes (see ericniebler/stl2#820, ericniebler/stl2#823).
      • Work around gcc-8 regression regarding volatile std::initializer_lists (see ericniebler/stl2#826).
      • Fix const-correctness problem of view::take.
    Source code(tar.gz)
    Source code(zip)
  • 0.3.5(Feb 17, 2018)

    0.3.5 February 17, 2018

    • Rvalues may satisfy Writable (see ericniebler/stl2#387).
    • view_interface gets a bounds-checking at method.
    • chunk_view works on Input ranges.
    • Fix bug in group_by_view.
    • Improved concept checks for partial_sum numeric algorithm.
    • Define ContiguousIterator concept and contiguous_iterator_tag iterator category tag.
    • Sundry span fixes.
    • action::insert avoids interfering with vector's exponentional growth strategy.
    • Add an experimental shared view for views that need container-like scratch space to do their work.
    • Faster, simpler reverse_view.
    • Rework ranges::reference_wrapper to avoid LWG#2993.
    • Reworked any_view, the type-erased view wrapper.
    • equal algorithm is constexpr in C++14.
    • stride_view no longer needs an atomic data member.
    • const-correct drop_view.
    • adjacent_filter_view supports bidirectional iteration.
    • Massive view_adaptor cleanup to remove the need for a mutable data member holding the adapted view.
    • Fix counting_iterator post-increment bug.
    • tail_view of an empty range is an empty range, not undefined behavior.
    • Various portability fixes for gcc and clang trunk.
    Source code(tar.gz)
    Source code(zip)
  • 0.3.0(Jun 30, 2017)

    0.3.0 June 30, 2017

    • Input views may now be move-only (from @CaseyCarter)
    • Input any_views are now much more efficient (from @CaseyCarter)
    • Better support for systems lacking a working <thread> header (from @CaseyCarter)
    Source code(tar.gz)
    Source code(zip)
  • 0.2.6(Jun 21, 2017)

    0.2.6 2017-06-21

    • Experimental coroutines with ranges::experimental::generator (from @CaseyCarter)
    • ranges::optional now behaves like std::optional (from @CaseyCarter)
    • Extensive bug fixes with Input ranges (from @CaseyCarter)
    Source code(tar.gz)
    Source code(zip)
  • 0.2.5(May 16, 2017)

    • view::chunk works on Input ranges (from @CaseyCarter)
    • for_each_n algorithm (from @khlebnikov)
    • Portability fixes for MinGW, clang-3.6 and -3.7, and gcc-7; and cmake 3.0
    Source code(tar.gz)
    Source code(zip)
  • 0.2.4(Apr 13, 2017)

    0.2.4 April 12, 2017 Fix the following bug:

    • action::stable_sort of vector broken on Clang 3.8.1 since ~last Xmas (ericniebler/range-v3#632).
    Source code(tar.gz)
    Source code(zip)
  • 0.2.3(Apr 4, 2017)

  • 0.2.2(Mar 30, 2017)

    New in this release:

    • view::linear_distribute(from,to,n) - A view of n elements between from and to, distributed evenly.
    • view::indices(n) - A view of the indices [0,1,2...n-1].
    • view::closed_indices(n) - A view of the indices [0,1,2...n].

    This release also deprecates view::ints(n) as confusing to new users.

    Source code(tar.gz)
    Source code(zip)
  • 0.2.1(Mar 22, 2017)

  • 0.2.0(Mar 13, 2017)

    Bring many interfaces into sync with the Ranges TS.

    • Many interfaces are simply renamed. The following table shows the old names and the new. (All names are in the ranges::v3 namespace.)

      | Old Name | New Name | |-------------------------------|---------------------------| | indirect_swap | iter_swap | | indirect_move | iter_move | | iterator_value_t | value_type_t | | iterator_reference_t | reference_t | | iterator_difference_t | difference_type_t | | iterator_size_t | size_type_t | | iterator_rvalue_reference_t | rvalue_reference_t | | iterator_common_reference_t | iter_common_reference_t | | range_value_t | range_value_type_t | | range_difference_t | range_difference_type_t | | range_size_t | range_size_type_t | | range_iterator_t | iterator_t | | range_sentinel_t | sentinel_t |

    • common_iterator now requires that its two types (Iterator and Sentinel) are different. Use common_iterator_t<I, S> to get the old behavior (i.e., if the two types are the same, it is an alias for I; otherwise, it is common_iterator<I, S>).

    • The following iterator adaptors now work with iterators that return proxies from their postfix increment operator (i.e., operator++(int)):

      • common_iterator
      • counted_iterator
    • The following customization points are now implemented per the Ranges TS spec and will no longer find the associated unconstrained overload in namespace std:::

      • ranges::begin
      • ranges::end
      • ranges::size
      • ranges::swap
      • ranges::iter_swap

      (In practice, this has very little effect but it may effect overloading in rare situations.)

    • ranges::is_swappable now only takes one template parameter. The new ranges::is_swappable_with<T, U> tests whether T and U are swappable. ranges::is_swappable<T> is equivalent to ranges::is_swappable_with<T &, T &>.

    • The following object concepts have changed to conform with the Ranges TS specification, and approved changes (see P0547):

      • Destructible
      • Constructible
      • DefaultConstructible
      • MoveConstructible
      • CopyConstructible
      • Movable
      • Assignable
    • The View concept is no longer satisfied by reference types.

    • is_view is now called enable_view

    • The syntax for defining a concept has changed slightly. See utility/iterator_concepts.hpp for examples.

    This release drops support for gcc 4.8.

    Source code(tar.gz)
    Source code(zip)
  • 0.1.1(Mar 13, 2017)

  • 0.1.0(Mar 8, 2017)

Owner
Eric Niebler
Member of the ISO C++ Standardization Committee and principal author of the Ranges TS.
Eric Niebler
A BOF to parse the imports of a provided PE-file, optionally extracting symbols on a per-dll basis.

PE Import Enumerator BOF What is this? This is a BOF to enumerate DLL files to-be-loaded by a given PE file. Depending on the number of arguments, thi

null 74 May 15, 2022
Basis Universal GPU Texture Codec

basis_universal Basis Universal Supercompressed GPU Texture Codec Basis Universal is a "supercompressed" GPU texture data interchange system that supp

null 2.1k Jun 25, 2022
Single-header, ranges-compatible generator type built on C++20 coroutines

generator Single-header, ranges-compatible generator type built with C++20 coroutines. A generator allows implementing sequence producers which are te

Sy Brand 26 Apr 26, 2022
Ranges that didn't make C++20

ranges Implementations of ranges that didn't make C++20. Coded live on Twitch. Types tl::enumerate_view/tl::views::enumerate A view which lets you ite

Sy Brand 53 May 24, 2022
Companion source code for "Programming with C++20 - Concepts, Coroutines, Ranges, and more"

Companion Source Code for "Programming with C++20 - Concepts, Coroutines, Ranges, and more" 1. Edition Code examples This repository contains runnable

Andreas Fertig 117 Jun 27, 2022
An Arduino library which allows you to communicate seamlessly with the full range of u-blox GNSS modules

u-blox makes some incredible GNSS receivers covering everything from low-cost, highly configurable modules such as the SAM-M8Q all the way up to the surveyor grade ZED-F9P with precision of the diameter of a dime.

SparkFun Electronics 112 Jun 22, 2022
A C++ concepts and range based character encoding and code point enumeration library

Travis CI (Linux:gcc) Text_view A C++ Concepts based character encoding and code point enumeration library. This project is the reference implementati

Tom Honermann 123 Jun 20, 2022
A header-only C++ library that enables the representation of a range of values in a linear space

Numeric Range A header-only C++ library that enables the representation of a range of values in a linear space (via the NumericRange class). The linea

Amal Bansode 4 Mar 22, 2022
RemixDB: A read- and write-optimized concurrent KV store. Fast point and range queries. Extremely low write-amplification.

REMIX and RemixDB The REMIX data structure was introduced in paper "REMIX: Efficient Range Query for LSM-trees", FAST'21. This repository maintains a

Xingbo Wu 72 Jun 26, 2022
An efficient, composable design pattern for range processing

Transrangers An efficient, composable design pattern for range processing. Intro Pull-based approach Push-based approach Transrangers Performance Tran

null 97 Apr 15, 2022
ZTE Nubia Z17 (codenamed "nx563j") is a high-range smartphone from Nubia.

ZTE Nubia Z17 (codenamed "nx563j") is a high-range smartphone from Nubia. It was released in June 2017.

null 2 Oct 25, 2021
Dynamic array supporting Range Minimum Queries

dynamic-RMQ Dynamic array supporting Range Minimum Queries. Data structure that represent a dynamic array supporting Range Minimum Queries. The data s

Massimiliano Rossi 3 Oct 31, 2021
Packages for simulating the Tethys-class Long-Range AUV (LRAUV) from the Monterey Bay Aquarium Research Institute (MBARI).

LRAUV Simulation This repository contains packages for simulating the Tethys-class Long-Range AUV (LRAUV) from the Monterey Bay Aquarium Research Inst

Open Robotics 17 Jun 22, 2022
Playbit System interface defines an OS-like computing platform which can be implemented on a wide range of hosts

PlaySys The Playbit System interface PlaySys defines an OS-like computing platform which can be implemented on a wide range of hosts like Linux, BSD,

Playbit 227 Jun 22, 2022
SX1276/77/78/79 Low Power Long Range Transceiver driver for esp-idf

esp-idf-sx127x SX1276/77/78/79 Low Power Long Range Transceiver driver for esp-idf. I based on this. Changes from the original Added support for ESP32

null 11 Jun 21, 2022
SX1262//68 Low Power Long Range Transceiver driver for esp-idf

esp-idf-sx126x SX1262//68 Low Power Long Range Transceiver driver for esp-idf. I ported from here. Ai-Thinker offers several LoRa modules. You can get

null 3 May 9, 2022
high performance C++20 implementation of std::variant

A minimal compile-time overhead, C++20 implementation of std::variant. Fully standard conforming with a couple of documented differences.

null 26 Apr 13, 2022
A cleaner and more intuitive std::variant alternative

[WIP] ExtendedVariant This single header library is part of my C++ extended standard stdex libraries. Check our my profile for more. Working with C++

pinsrq 3 Jun 13, 2021
std::find simd version

std::find simd version std::find doesn't use simd intrinsics. ( check https://gms.tf/stdfind-and-memchr-optimizations.html ) So i thought simd can mak

SungJinKang 19 Jan 5, 2022