Mercurial > octave
changeset 31383:fa025af77216
Array: Export constructor that is needed in different library (bug #61711).
* liboctave/array/Array.h (Array::Array): Mark constructor with custom allocator
for dllexport.
* liboctave/array/Array.cc (Array::Array): Move definition of that constructor
here.
* libinterp/corefcn/mex.cc: Do not include "Array.cc". We no longer need to
implicitly instantiate the Array template class in liboctinterp with types that
are exported (with spezializations) from liboctave.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Tue, 01 Nov 2022 12:19:33 +0100 |
parents | cad5406329be |
children | 7802c652081f |
files | libinterp/corefcn/mex.cc liboctave/array/Array.cc liboctave/array/Array.h |
diffstat | 3 files changed, 15 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/mex.cc Tue Nov 01 06:36:30 2022 -0400 +++ b/libinterp/corefcn/mex.cc Tue Nov 01 12:19:33 2022 +0100 @@ -46,10 +46,6 @@ #include <set> #include <string> -#if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR) -// Needed to instantiate Array objects with custom allocator. -# include "Array.cc" -#endif #include "f77-fcn.h" #include "lo-ieee.h" #include "oct-locbuf.h" @@ -75,21 +71,6 @@ #include "variables.h" #include "graphics.h" - -// Prevent implicit instantiations without the necessary specializations -// on some platforms (Windows, others?). - -extern template class Array<Complex>; -extern template class Array<FloatComplex>; -extern template class Array<bool>; -extern template class Array<char>; -extern template class Array<double>; -extern template class Array<float>; -extern template class Array<octave::idx_vector>; -extern template class Array<octave_idx_type>; -extern template class Array<std::string>; - - // These must be declared extern "C" but may be omitted from the set of // symbols declared in mexproto.h, so we declare them here as well.
--- a/liboctave/array/Array.cc Tue Nov 01 06:36:30 2022 -0400 +++ b/liboctave/array/Array.cc Tue Nov 01 12:19:33 2022 +0100 @@ -86,6 +86,19 @@ m_dimensions.chop_trailing_singletons (); } +// We need to dllexport this constructor from explicit template +// instantiations with specializations. One way to do this is to mark the +// declaration with the corresponding attributes and define the +// constructor separately here. +template <typename T, typename Alloc> +Array<T, Alloc>::Array (T *ptr, const dim_vector& dv, const Alloc& xallocator) + : m_dimensions (dv), + m_rep (new typename Array<T, Alloc>::ArrayRep (ptr, dv, xallocator)), + m_slice_data (m_rep->m_data), m_slice_len (m_rep->m_len) +{ + m_dimensions.chop_trailing_singletons (); +} + template <typename T, typename Alloc> void Array<T, Alloc>::fill (const T& val)
--- a/liboctave/array/Array.h Tue Nov 01 06:36:30 2022 -0400 +++ b/liboctave/array/Array.h Tue Nov 01 12:19:33 2022 +0100 @@ -303,14 +303,9 @@ // object is deleted. The dimension vector DV must be consistent with // the size of the allocated PTR array. + OCTARRAY_API explicit Array (T *ptr, const dim_vector& dv, - const Alloc& xallocator = Alloc ()) - : m_dimensions (dv), - m_rep (new typename Array<T, Alloc>::ArrayRep (ptr, dv, xallocator)), - m_slice_data (m_rep->m_data), m_slice_len (m_rep->m_len) - { - m_dimensions.chop_trailing_singletons (); - } + const Alloc& xallocator = Alloc ()); //! Reshape constructor. OCTARRAY_API Array (const Array<T, Alloc>& a, const dim_vector& dv);