Skip to content

Commit 41ec178

Browse files
authored
Replace usage of std::is_pod (#7303)
Replaces usages of `std::is_pod` with the suggested alternative by gcc - `std::is_standard_layout && std::is_trivial`. `std::is_pod` is deprecated in C++20, hence this replacement is necessary to make usage of open3d possible when client code is compiled with C++20. Fixes part of #5405
1 parent 29e6c81 commit 41ec178

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
- Add error handling for insufficient correspondences in AdvancedMatching (PR #7234)
6363
- Exposed `get_plotly_fig` and modified `draw_plotly` to return the `Figure` it creates. (PR #7258)
6464
- Fix build with librealsense v2.44.0 and upcoming VS 2022 17.13 (PR #7074)
65+
- Fix `deprecated-declarations` warnings when compiling code with C++20 standard (PR #7303)
6566

6667
## 0.13
6768

cpp/open3d/core/Tensor.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ class Tensor : public IsDevice {
6262

6363
// Check data types
6464
AssertTemplateDtype<T>();
65-
if (!std::is_pod<T>()) {
66-
utility::LogError("Object must be a POD.");
65+
if (!(std::is_standard_layout<T>::value && std::is_trivial<T>::value)) {
66+
utility::LogError(
67+
"Object must be a StandardLayout and TrivialType type.");
6768
}
6869

6970
// Copy data to blob
@@ -1432,4 +1433,4 @@ inline void AssertNotSYCL(const Tensor& tensor) {
14321433
}
14331434

14341435
} // namespace core
1435-
} // namespace open3d
1436+
} // namespace open3d

cpp/open3d/ml/contrib/Cloud.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ namespace open3d {
5353
namespace ml {
5454
namespace contrib {
5555

56-
static_assert(std::is_pod<PointXYZ>(), "PointXYZ class must be a POD type.");
56+
static_assert(std::is_standard_layout<PointXYZ>::value &&
57+
std::is_trivial<PointXYZ>::value,
58+
"PointXYZ class must be a StandardLayout and TrivialType type.");
5759

5860
// Getters
5961
// *******

cpp/tests/core/TensorObject.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ class TestObject {
4848
void *ptr_;
4949
};
5050

51-
static_assert(std::is_pod<TestObject>(), "TestObject must be a POD.");
51+
static_assert(std::is_standard_layout<TestObject>::value &&
52+
std::is_trivial<TestObject>::value,
53+
"TestObject must be a StandardLayout and TrivialType type.");
5254
static const int64_t byte_size = sizeof(TestObject);
5355
static const std::string class_name = "TestObject";
5456

0 commit comments

Comments
 (0)