Non-list-initialization (parentheses) and list-initialization (curly braces) styles are mixed in the <ranges>, however, the latter does not provide any observable benefit and may bring potential issues.
We should use non-list-initialization consistently, as the standard does.
#include <ranges>
#include <initializer_list>
#include <utility>
struct I {
using difference_type = int;
using value_type = int;
I(std::initializer_list<int*>) = delete;
I(int*);
int operator*() const;
I& operator++();
I operator++(int);
};
struct R {
int* begin();
I begin() const;
std::unreachable_sentinel_t end() const;
};
int main() {
auto r = R{} | std::views::transform(std::identity{});
decltype(std::as_const(r).begin()) c = r.begin();
}
https://godbolt.org/z/89eo678qd
Non-list-initialization (parentheses) and list-initialization (curly braces) styles are mixed in the
<ranges>, however, the latter does not provide any observable benefit and may bring potential issues.We should use non-list-initialization consistently, as the standard does.
https://godbolt.org/z/89eo678qd