From 3491dc0acddf60eb8c9c8f8b3a67f4c9cdd53dbc Mon Sep 17 00:00:00 2001 From: Luc Grosheintz Date: Tue, 20 Feb 2024 17:03:16 +0100 Subject: [PATCH] Allow default ctors. --- include/highfive/H5DataSet.hpp | 2 +- tests/unit/tests_high_five_base.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/highfive/H5DataSet.hpp b/include/highfive/H5DataSet.hpp index 4a582630b..566eb17ff 100644 --- a/include/highfive/H5DataSet.hpp +++ b/include/highfive/H5DataSet.hpp @@ -98,7 +98,7 @@ class DataSet: public Object, return details::get_plist(*this, H5Dget_access_plist); } - DataSet() = delete; + DataSet() = default; protected: using Object::Object; // bring DataSet(hid_t) diff --git a/tests/unit/tests_high_five_base.cpp b/tests/unit/tests_high_five_base.cpp index ca8df666a..f134634f0 100644 --- a/tests/unit/tests_high_five_base.cpp +++ b/tests/unit/tests_high_five_base.cpp @@ -312,6 +312,19 @@ TEST_CASE("Test allocation time") { CHECK(alloc_size == data.size() * sizeof(decltype(data)::value_type)); } +TEST_CASE("Test default constructors") { + const std::string file_name("h5_default_ctors.h5"); + const std::string dataset_name("dset"); + File file(file_name, File::Truncate); + auto ds = file.createDataSet(dataset_name, std::vector{1, 2, 3, 4, 5}); + + DataSet d2; + CHECK_THROWS(d2.getFile()); + CHECK(!d2.isValid()); + d2 = ds; // copy + CHECK(d2.isValid()); +} + TEST_CASE("Test groups and datasets") { const std::string file_name("h5_group_test.h5"); const std::string dataset_name("dset");