PLSSVM - Parallel Least Squares Support Vector Machine  2.0.0
A Least Squares Support Vector Machine implementation using different backends.
error_code.hpp
Go to the documentation of this file.
1 
12 #ifndef PLSSVM_BACKENDS_OPENCL_DETAIL_ERROR_CODE_HPP_
13 #define PLSSVM_BACKENDS_OPENCL_DETAIL_ERROR_CODE_HPP_
14 #pragma once
15 
16 #include "CL/cl.h" // cl_int, CL_SUCCESS
17 
18 #include <iosfwd> // forward declare std::ostream
19 #include <string_view> // std::string_view
20 
21 namespace plssvm::opencl::detail {
22 
27 class error_code {
28  public:
32  error_code() = default;
37  error_code(cl_int error) noexcept;
38 
44  error_code &operator=(cl_int error) noexcept;
49  void assign(cl_int error) noexcept;
50 
54  void clear() noexcept;
55 
60  [[nodiscard]] cl_int value() const noexcept;
65  [[nodiscard]] std::string_view message() const noexcept;
70  [[nodiscard]] explicit operator bool() const noexcept;
75  [[nodiscard]] cl_int *operator&() noexcept;
76 
77  private:
79  cl_int err_{ CL_SUCCESS };
80 };
81 
92 std::ostream &operator<<(std::ostream &out, error_code ec);
99 [[nodiscard]] bool operator==(error_code lhs, error_code rhs) noexcept;
106 [[nodiscard]] bool operator!=(error_code lhs, error_code rhs) noexcept;
107 
108 } // namespace plssvm::opencl::detail
109 
110 #endif // PLSSVM_BACKENDS_OPENCL_DETAIL_ERROR_CODE_HPP_
Class wrapping an OpenCL error code.
Definition: error_code.hpp:27
error_code()=default
Construct a new error code indicating success (CL_SUCCESS).
void assign(cl_int error) noexcept
Assign the OpenCL error code to *this.
std::string_view message() const noexcept
Obtains the explanatory string of the error code.
void clear() noexcept
Sets to error code value back to CL_SUCCESS.
error_code & operator=(cl_int error) noexcept
Assign the OpenCL error code to *this.
error_code(cl_int error) noexcept
Construct a new error code wrapping the OpenCL error code.
cl_int err_
The wrapped OpenCL error code.
Definition: error_code.hpp:79
cl_int value() const noexcept
Obtain the value of the error code.
Namespace containing OpenCL backend specific implementation details. Should not directly be used by u...
Definition: command_queue.hpp:22
std::ostream & operator<<(std::ostream &out, error_code ec)
Output the error code encapsulated by ev to the given output-stream out.
bool operator!=(error_code lhs, error_code rhs) noexcept
Compares two error codes for inequality.
bool operator==(error_code lhs, error_code rhs) noexcept
Compares two error codes for equality.