From 57707433592180a9fa66a75cf01bd9c3dab89d22 Mon Sep 17 00:00:00 2001 From: Gopi Krishna Menon Date: Mon, 21 Sep 2020 05:53:45 +0530 Subject: [PATCH] Replaced storage container for HDU (vec-deque) to prevent reference invalidation --- include/boost/astronomy/io/fits_reader.hpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/include/boost/astronomy/io/fits_reader.hpp b/include/boost/astronomy/io/fits_reader.hpp index e004b2ad..70bed046 100644 --- a/include/boost/astronomy/io/fits_reader.hpp +++ b/include/boost/astronomy/io/fits_reader.hpp @@ -9,9 +9,8 @@ file License.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_ASTRONOMY_IO_FITS_READER_HPP #define BOOST_ASTRONOMY_IO_FITS_READER_HPP -#include +#include #include -#include #include #include @@ -59,7 +58,7 @@ namespace boost { namespace astronomy { namespace io { struct fits_io { private: FileReader file_reader; - std::vector hdu_list; + std::deque hdu_list; control_block hdus_control_block; public: /** @@ -148,28 +147,28 @@ namespace boost { namespace astronomy { namespace io { /** * @brief Returns the HDU at given index */ - typename ExtensionsSupported::Extension& operator [](int index) { + typename ExtensionsSupported::Extension& operator [](int index) { return hdu_list.at(index); } /** * @brief Returns the HDU based on the hdu_name */ - typename ExtensionsSupported::Extension& operator [](const std::string& hdu_name) { + typename ExtensionsSupported::Extension& operator [](const std::string& hdu_name) { return hdu_list[hdus_control_block.hdus_info.at(hdu_name).hdu_index]; } /** * @brief Returns the list of hdu objects associated with a FITS file */ - std::vector get_hdu_list() { + std::deque get_hdu_list() const { return hdu_list; } /** * @brief Returns the control block containing the hdu cache information */ - control_block get_control_block_info() { + control_block get_control_block_info() const { return hdus_control_block; }