ericniebler / range-v3

Range library for C++14/17/20, basis for C++20's std::ranges
Other
4.05k stars 437 forks source link

ranges::transform cannot be compiled with c++17 #1822

Open hj2000 opened 1 week ago

hj2000 commented 1 week ago

Can you explain why ranges::tranform can be compiled with c++20, but failed to be compiled with c++17?

#include <algorithm>
#include <cmath>
#include <iterator>
#include <set>
#include <range/v3/algorithm.hpp>

int main () {
    std::vector<double> a{1.5,2.5,3.5};
    std::set<double> b;

    std::ranges::transform( a, std::inserter( b, b.begin() ), 
        []( double v ) -> double { return std::round( v ); } ); // compiles with c++20
    ranges::transform( a, std::inserter( b, b.begin() ), 
        []( double v ) -> double { return std::round( v ); } ); // compiles with c++20, but does not compile with c++17

    return 0;
}

gcc version: 14.1 range-v3 version: 0.12.0