A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/llvm/llvm-project/issues/132133 below:

[libc++][ranges] `ranges::to` can have non-class return type · Issue #132133 · llvm/llvm-project · GitHub

Currently, this ill-formed program which violates [range.utility.conv.to]/1 and [range.utility.conv.adaptors]/1 isn't rejected when using libc++ (Godbolt link):

#include <concepts>
#include <ranges>

int main() {
  struct R {
    int* begin() const;
    int* end() const;

    operator int() const { return 0; }
  };

  std::same_as<int> auto m [[maybe_unused]] = std::ranges::to<int>(R{});
  std::same_as<int> auto n [[maybe_unused]] = R{} | std::ranges::to<int>();
}

It's weird that the "class" part is mentioned in comments but not actually implemented.

// Mandates: C is a cv-unqualified class type. static_assert(!is_const_v<_Container>, "The target container cannot be const-qualified, please remove the const"); static_assert( !is_volatile_v<_Container>, "The target container cannot be volatile-qualified, please remove the volatile"); // Mandates: C is a cv-unqualified class type. static_assert(!is_const_v<_Container>, "The target container cannot be const-qualified, please remove the const"); static_assert( !is_volatile_v<_Container>, "The target container cannot be volatile-qualified, please remove the volatile");

Note that libstdc++ and MSVC STL also reject union types by only using is_class_v, despite that the term "class type" in the C++ core language specification also covers union types. Perhaps we should also only accept non-union class types here and submit an LWG issue for this.

Edit: LWG4229


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4