1
1
// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning
2
2
// expected-no-diagnostics
3
- // ==------------------- buffer_ctad.cpp - SYCL buffer CTAD test ----------------==//
4
- //
5
- // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6
- // See https://llvm.org/LICENSE.txt for license information.
7
- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8
- //
9
- // ===----------------------------------------------------------------------===//
10
3
11
4
#include < CL/sycl.hpp>
12
5
#include < cassert>
@@ -19,22 +12,45 @@ int main() {
19
12
const std::vector<int > cv (5 , 1 );
20
13
buffer b1 (v.data (), range<1 >(5 ));
21
14
static_assert (std::is_same<decltype (b1), buffer<int , 1 >>::value);
15
+
22
16
buffer b1a (v.data (), range<1 >(5 ), std::allocator<int >());
23
17
static_assert (
24
18
std::is_same<decltype (b1a), buffer<int , 1 , std::allocator<int >>>::value);
19
+
25
20
buffer b1b (cv.data (), range<1 >(5 ));
26
21
static_assert (std::is_same<decltype (b1b), buffer<int , 1 >>::value);
22
+
27
23
buffer b1c (v.data (), range<2 >(2 , 2 ));
28
24
static_assert (std::is_same<decltype (b1c), buffer<int , 2 >>::value);
25
+
29
26
buffer b2 (v.begin (), v.end ());
30
27
static_assert (std::is_same<decltype (b2), buffer<int , 1 >>::value);
28
+
31
29
buffer b2a (v.cbegin (), v.cend ());
32
30
static_assert (std::is_same<decltype (b2a), buffer<int , 1 >>::value);
31
+
33
32
buffer b3 (v);
34
33
static_assert (std::is_same<decltype (b3), buffer<int , 1 >>::value);
34
+
35
35
buffer b3a (cv);
36
36
static_assert (std::is_same<decltype (b3a), buffer<int , 1 >>::value);
37
+
37
38
shared_ptr_class<int > ptr{new int [5 ], [](int *p) { delete[] p; }};
38
39
buffer b4 (ptr, range<1 >(5 ));
39
40
static_assert (std::is_same<decltype (b4), buffer<int , 1 >>::value);
41
+
42
+ std::allocator<int > buf_alloc;
43
+ shared_ptr_class<int > ptr_alloc{new int [5 ], [](int *p) { delete[] p; }};
44
+ buffer b5 (ptr, range<1 >(5 ), buf_alloc);
45
+ static_assert (std::is_same<decltype (b5),
46
+ buffer<int , 1 , std::allocator<int >>>::value);
47
+
48
+ shared_ptr_class<int []> arr_ptr{new int [5 ]};
49
+ buffer b6 (arr_ptr, range<1 >(5 ));
50
+ static_assert (std::is_same<decltype (b6), buffer<int , 1 >>::value);
51
+
52
+ shared_ptr_class<int []> arr_ptr_alloc{new int [5 ]};
53
+ buffer b7 (arr_ptr_alloc, range<1 >(5 ), buf_alloc);
54
+ static_assert (std::is_same<decltype (b7),
55
+ buffer<int , 1 , std::allocator<int >>>::value);
40
56
}
0 commit comments