Skip to content

Commit c220eb8

Browse files
authored
[SYCL] Make context constructors explicit to avoid unintended conversions (#1219)
Signed-off-by: James Brodman <[email protected]>
1 parent 4b5d25b commit c220eb8

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

sycl/include/CL/sycl/context.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ class context {
4949
/// @param AsyncHandler is an instance of async_handler.
5050
/// @param UseCUDAPrimaryContext is a bool determining whether to use the
5151
/// primary context in the CUDA backend.
52-
context(const device &Device, async_handler AsyncHandler = {},
53-
bool UseCUDAPrimaryContext = false);
52+
explicit context(const device &Device, async_handler AsyncHandler = {},
53+
bool UseCUDAPrimaryContext = false);
5454

5555
/// Constructs a SYCL context instance using the provided platform.
5656
///
@@ -63,8 +63,8 @@ class context {
6363
/// @param AsyncHandler is an instance of async_handler.
6464
/// @param UseCUDAPrimaryContext is a bool determining whether to use the
6565
/// primary context in the CUDA backend.
66-
context(const platform &Platform, async_handler AsyncHandler = {},
67-
bool UseCUDAPrimaryContext = false);
66+
explicit context(const platform &Platform, async_handler AsyncHandler = {},
67+
bool UseCUDAPrimaryContext = false);
6868

6969
/// Constructs a SYCL context instance using list of devices.
7070
///
@@ -78,8 +78,9 @@ class context {
7878
/// @param AsyncHandler is an instance of async_handler.
7979
/// @param UseCUDAPrimaryContext is a bool determining whether to use the
8080
/// primary context in the CUDA backend.
81-
context(const vector_class<device> &DeviceList,
82-
async_handler AsyncHandler = {}, bool UseCUDAPrimaryContext = false);
81+
explicit context(const vector_class<device> &DeviceList,
82+
async_handler AsyncHandler = {},
83+
bool UseCUDAPrimaryContext = false);
8384

8485
/// Constructs a SYCL context instance from OpenCL cl_context.
8586
///

0 commit comments

Comments
 (0)