xref: /llvm-project/libcxx/test/std/ranges/range.access/begin.sizezero.pass.cpp (revision d2baefae6846765eef6a6dd69d4fdf1082ce29ad)
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
10 // UNSUPPORTED: msvc
11 
12 // std::ranges::begin
13 // std::ranges::cbegin
14 //   Test the fix for https://llvm.org/PR54100
15 
16 #include <ranges>
17 #include <cassert>
18 
19 #include "test_macros.h"
20 
21 struct A {
22   int m[0];
23 };
24 static_assert(sizeof(A) == 0); // an extension supported by GCC and Clang
25 
main(int,char **)26 int main(int, char**)
27 {
28   A a[10];
29   std::same_as<A*> auto p = std::ranges::begin(a);
30   assert(p == a);
31   std::same_as<const A*> auto cp = std::ranges::cbegin(a);
32   assert(cp == a);
33 
34   return 0;
35 }
36