54 lines · cpp
1// RUN: %clang_cc1 -std=c++2c -fexperimental-new-constant-interpreter -verify=expected,both %s2// RUN: %clang_cc1 -std=c++2c -verify=ref,both %s3 4// both-no-diagnostics5 6namespace std {7template <class, int __v> struct integral_constant {8 static const int value = __v;9};10using size_t = decltype(sizeof(int));11template <class _Tp, class>12concept __weakly_equality_comparable_with = requires(_Tp __t) { __t; };13template <size_t, class> struct tuple_element;14template <class> struct tuple_size;15template <class _Ip>16concept input_or_output_iterator = requires(_Ip __i) { __i; };17template <class _Sp, class _Ip>18concept sentinel_for = __weakly_equality_comparable_with<_Sp, _Ip>;19namespace ranges {20enum subrange_kind { unsized };21template <input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent,22 subrange_kind = unsized>23struct subrange {24 _Iter __begin_;25 _Sent __end_;26 constexpr _Sent end() { return __end_; }27};28template <int, class _Iter, class _Sent, subrange_kind _Kind>29constexpr auto get(subrange<_Iter, _Sent, _Kind> __subrange) {30 return __subrange.end();31}32} // namespace ranges33template <class _Ip, class _Sp, ranges::subrange_kind _Kp>34struct tuple_size<ranges::subrange<_Ip, _Sp, _Kp>>35 : integral_constant<size_t, 2> {};36template <class _Ip, class _Sp, ranges::subrange_kind _Kp>37struct tuple_element<0, ranges::subrange<_Ip, _Sp, _Kp>> {38 using type = _Ip;39};40template <class _Ip, class _Sp, ranges::subrange_kind _Kp>41struct tuple_element<1, ranges::subrange<_Ip, _Sp, _Kp>> {42 using type = _Sp;43};44} // namespace std45constexpr bool test() {46 int a[1];47 auto r = std::ranges::subrange(a, a);48 auto [first, last] = r;49 last = a;50 return true;51}52static_assert(test());53 54