From 8f507d8d6c0e1ed296c66561d4a18f3229a70955 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Mon, 14 Nov 2022 09:14:41 -0500 Subject: [PATCH 1/2] shared_ptr::operator bool() does not mean uninitialized, Tensor::empty() uses shared_ptr::use_count()==0 instead --- src/TiledArray/tensor/tensor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TiledArray/tensor/tensor.h b/src/TiledArray/tensor/tensor.h index ed0500d7e7..19452eb233 100644 --- a/src/TiledArray/tensor/tensor.h +++ b/src/TiledArray/tensor/tensor.h @@ -636,7 +636,7 @@ class Tensor { /// \return \c true if this tensor was default constructed (contains no /// data), otherwise \c false. - bool empty() const { return !this->data_; } + bool empty() const { return this->data_.use_count() == 0; } /// MADNESS serialization function From 9c1b4f6aaeb4133bc52511b0197c49f57a08ded6 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Mon, 14 Nov 2022 09:15:15 -0500 Subject: [PATCH 2/2] fixup empty(tensors...) to work correctly --- src/TiledArray/tensor/utility.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TiledArray/tensor/utility.h b/src/TiledArray/tensor/utility.h index 6ba90f2fb3..6526691cb7 100644 --- a/src/TiledArray/tensor/utility.h +++ b/src/TiledArray/tensor/utility.h @@ -316,8 +316,8 @@ inline typename T::size_type inner_size(const T& tensor) { /// This function is used as the termination step for the recursive empty() /// function. It also handles the case where there are no tensors in the /// list. -/// \return \c true -inline constexpr bool empty() { return true; } +/// \return \c false +inline constexpr bool empty() { return false; } /// Test for empty tensors