From 15f8e04308bbd44ed378ee7aa6ce32555c20e7e6 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Thu, 9 Jun 2022 11:12:37 +0300 Subject: [PATCH] Fix util::flat_list::data() --- libs/util/include/psemek/util/flat_list.hpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libs/util/include/psemek/util/flat_list.hpp b/libs/util/include/psemek/util/flat_list.hpp index 8a0a4011..878fec9c 100644 --- a/libs/util/include/psemek/util/flat_list.hpp +++ b/libs/util/include/psemek/util/flat_list.hpp @@ -34,8 +34,17 @@ namespace psemek::util std::size_t capacity() const { return capacity_; } bool empty() const { return size_ == 0; } - T * data() { return nodes_.get(); } - T const * data() const { return nodes_.get(); } + T * data() + { + static_assert(sizeof(node) == sizeof(T)); + return reinterpret_cast(nodes_.get()); + } + + T const * data() const + { + static_assert(sizeof(node) == sizeof(T)); + return reinterpret_cast(nodes_.get()); + } void reserve(std::size_t size); void clear();