Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use compiler generated functions in host_ptr and local_ptr #236

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/care/host_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ namespace care {
///
/// Default constructor
///
host_ptr() noexcept : m_ptr(nullptr) {}
host_ptr() = default;

///
/// @author Peter Robinson
///
/// nullptr constructor
///
host_ptr(std::nullptr_t) noexcept : m_ptr(nullptr) {}
host_ptr(std::nullptr_t) noexcept : host_ptr() {}

///
/// @author Peter Robinson
Expand All @@ -63,7 +63,7 @@ namespace care {
///
/// Copy constructor
///
host_ptr(host_ptr const & ptr) noexcept : m_ptr(ptr.data()) {}
host_ptr(host_ptr const & ptr) = default;

///
/// @author Peter Robinson
Expand All @@ -72,7 +72,7 @@ namespace care {
///
template <bool B = std::is_const<T>::value,
typename std::enable_if<B, int>::type = 1>
host_ptr<T>(host_ptr<T_non_const> const &ptr) noexcept : m_ptr(ptr.data()) {}
host_ptr<T>(host_ptr<T_non_const> const &ptr) noexcept : m_ptr(ptr.m_ptr) {}

///
/// @author Peter Robinson
Expand Down Expand Up @@ -178,7 +178,7 @@ namespace care {
}

private:
T * m_ptr; //!< Raw host pointer
T* m_ptr = nullptr; //!< Raw host pointer
};

/// Comparison operators
Expand Down
11 changes: 6 additions & 5 deletions src/care/local_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ namespace care {
///
/// Default constructor
///
CARE_HOST_DEVICE local_ptr() noexcept : m_ptr(nullptr) {}
CARE_HOST_DEVICE local_ptr() = default;

///
/// @author Alan Dayton
///
/// nullptr constructor
///
CARE_HOST_DEVICE local_ptr(std::nullptr_t) noexcept : m_ptr(nullptr) {}
CARE_HOST_DEVICE local_ptr(std::nullptr_t) noexcept : local_ptr() {}

///
/// @author Peter Robinson
Expand All @@ -53,11 +53,12 @@ namespace care {
///
CARE_HOST_DEVICE local_ptr(T* ptr) noexcept : m_ptr(ptr) {}

///
/// @author Peter Robinson
///
/// Copy constructor
///
CARE_HOST_DEVICE local_ptr(local_ptr const &ptr) noexcept : m_ptr(ptr) {}
CARE_HOST_DEVICE local_ptr(local_ptr const &ptr) = default;

///
/// @author Peter Robinson
Expand All @@ -66,7 +67,7 @@ namespace care {
///
template <bool B = std::is_const<T>::value,
typename std::enable_if<B, int>::type = 1>
CARE_HOST_DEVICE local_ptr<T>(local_ptr<T_non_const> const &ptr) noexcept : m_ptr(ptr) {}
CARE_HOST_DEVICE local_ptr<T>(local_ptr<T_non_const> const &ptr) noexcept : m_ptr(ptr.m_ptr) {}

///
/// @author Peter Robinson
Expand Down Expand Up @@ -134,7 +135,7 @@ namespace care {
CARE_HOST_DEVICE const T* cdata() const { return m_ptr; }

private:
T * m_ptr; //!< Raw pointer
T* m_ptr = nullptr; //!< Raw pointer
};
} // namespace care

Expand Down
Loading