Hi,

using MSVC 2019 in debug mode I get an exception "cannot compare
incompatible string_view iterators for equality". Using release mode and
Clang/G++ all went fine as expected.

- Boost: 1.76
- Visual Studio 2019 16.10.3 in C++17 mode

How can it changed to be "portable" for all compiler? What's the reason
behind? Using range.data() + size or data.front() + size for e.g. end
iterator didn't compile.

Thanks in advance!
Olaf

#include <boost/iterator/filter_iterator.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/range/iterator_range_io.hpp>
#include <string_view>
#include <iostream>

template <typename RangeType>
static auto filter_range(RangeType const& range)
{
    struct separator_predicate {
        bool operator()(char x) { return '_' != x; }
    };

    // FixMe: MSVC 2019 with '_CONTAINER_DEBUG_LEVEL > 0' triggers
    // assertion:
    // "cannot compare incompatible string_view iterators for equality"
    return boost::make_iterator_range(
        boost::make_filter_iterator(
            separator_predicate{}, range.begin(), range.end()),
        boost::make_filter_iterator(
            separator_predicate{}, range.end()));
}

using iterator_type = std::basic_string_view<char>::const_iterator;
using string_span = boost::iterator_range<iterator_type>;


int main()
{
    // input
    std::string_view const sv = "Hello_World";

    // algorithm get boost::iterator_range, aka string_span
    auto const range = string_span(sv);

    // here we are
    auto const range_f = filter_range(range);
    std::cout << range_f << '\n';
}
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
https://lists.boost.org/mailman/listinfo.cgi/boost-users

Reply via email to