https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117849

            Bug ID: 117849
           Summary: constraint variable in requires expression rejected,
                    but P2280R4 made it valid
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mkretz at gcc dot gnu.org
  Target Milestone: ---

Testcase (https://godbolt.org/z/Mfd85Wcn9):

-------------------
#include <ranges>
#include <array>
#include <vector>

template<typename T>
concept StaticSizedRange = std::ranges::sized_range<T> && requires (T&& t) {
    typename std::integral_constant<std::size_t, std::ranges::size(t)>;
};

static_assert(StaticSizedRange<std::array<int, 5>>);
static_assert(StaticSizedRange<std::array<int, 5>&>);
static_assert(StaticSizedRange<const std::array<int, 5>&>);
static_assert(!StaticSizedRange<std::vector<int>>);
-------------------

<source>:7:70: error: template argument 2 is invalid
    7 |     typename std::integral_constant<std::size_t, std::ranges::size(t)>;
      |                                                                      ^

However, testing 'std::ranges::size(t) >= 0' is valid for the array assertions.
P2280R4 / [expr.const]/10 (https://eel.is/c++draft/expr.const#10) say that this
should work.

Reply via email to