I wonder if the std::ranges::* algorithms should be working with std::initializer_list.
For example, line (B) in the following snippet compiles while line (A) does not, when compiling with x64 MSVC v19.latest and option /std:c++latest (godbolt.org/z/5oTEz1q5P).
#include <algorithm>
#include <array>
#define ONE 1
#define TWO 2
static_assert(std::ranges::is_sorted({ ONE, TWO })); // (A)
static_assert(std::ranges::is_sorted(std::array { ONE, TWO })); // (B)
int main() {}
The underlying temporary array that is allocated for the initializer_list should live until the call to is_sorted() in line (A) has returned.
According to the error message, std::initializer_list cannot be casted to a std::ranges::forward_range:
algorithm(10432): 'bool std::ranges::_Is_sorted_fn::operator ()(_Rng &&,_Pr,_Pj) const': could not deduce template argument for '_Rng'.
Is this the same reason as this one?