From c1c7fc833dd4b5e25c6881290053e9d17022752b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Pedro=20Bol=C3=ADvar=20Puente?= Date: Wed, 5 Jun 2019 12:27:28 +0200 Subject: [PATCH] Fix array::empty --- immer/array.hpp | 2 +- test/vector/generic.ipp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/immer/array.hpp b/immer/array.hpp index 43954bb8..d9e458e3 100644 --- a/immer/array.hpp +++ b/immer/array.hpp @@ -132,7 +132,7 @@ class array * Returns `true` if there are no elements in the container. It * does not allocate memory and its complexity is @f$ O(1) @f$. */ - IMMER_NODISCARD bool empty() const { return impl_.d->empty(); } + IMMER_NODISCARD bool empty() const { return impl_.size == 0; } /*! * Access the raw data. diff --git a/test/vector/generic.ipp b/test/vector/generic.ipp index ee6edde1..c1f94a66 100644 --- a/test/vector/generic.ipp +++ b/test/vector/generic.ipp @@ -55,12 +55,14 @@ TEST_CASE("instantiation") { auto v = VECTOR_T{}; CHECK(v.size() == 0u); + CHECK(v.empty()); } SECTION("initializer list") { auto v = VECTOR_T{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; CHECK_VECTOR_EQUALS(v, boost::irange(0u, 10u)); + CHECK(!v.empty()); } SECTION("big object")