Skip to content

Range Algorithms do not compile with std::span #142

@gcerretani

Description

@gcerretani

Algorithms like find_if do not compile when used on instances of std::span. They work with boost::span.

You can try this code on https://godbolt.org/z/Mq4GhqMYn:

#include <ranges>
#include <span>

#include <boost/core/span.hpp>
#include <boost/range/algorithm/find.hpp>

constexpr int a[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
boost::span boost_span{a};
std::span std_span{a};

auto foo0() {
    return boost::range::find(boost_span, 2); // ok
}

auto foo1() {
    return boost::range::find(std_span, 2); // fails
}

auto foo2() {
    return std::ranges::find(boost_span, 2); // ok
}

auto foo3() {
    return std::ranges::find(std_span, 2); // ok
}

The error message is something like

error: no type named 'type' in 'struct boost::range_iterator<const std::span<const int, 9>, void>'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions