Mercurial > octave
changeset 32909:37cb0ade8b01
Array: Avoid implicitly instantiating template class in its declaration.
* Array.h: Forward declare template class with visibility attributes.
(Array<T, Alloc>::compute_index_unchecked, Array<T, Alloc>::index,
Array<T, Alloc>::assign): Avoid defining member functions in template class
declaration that would lead to implicit instantiations of the template class.
* Array-base.cc (Array<T, Alloc>::compute_index_unchecked,
Array<T, Alloc>::index, Array<T, Alloc>::assign): Move definition of template
class member functions from header to here.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Fri, 02 Feb 2024 17:15:09 +0100 |
parents | b815641a6bcc |
children | 0e0b158f4cf9 |
files | liboctave/array/Array-base.cc liboctave/array/Array.h |
diffstat | 2 files changed, 31 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/array/Array-base.cc Fri Feb 02 17:20:38 2024 +0100 +++ b/liboctave/array/Array-base.cc Fri Feb 02 17:15:09 2024 +0100 @@ -210,6 +210,13 @@ } template <typename T, typename Alloc> +octave_idx_type +Array<T, Alloc>::compute_index_unchecked (const Array<octave_idx_type>& ra_idx) const +{ + return m_dimensions.compute_index (ra_idx.data (), ra_idx.numel ()); +} + +template <typename T, typename Alloc> T& Array<T, Alloc>::checkelem (octave_idx_type n) { @@ -1124,6 +1131,13 @@ } template <typename T, typename Alloc> +Array<T, Alloc> +Array<T, Alloc>::index (const Array<octave::idx_vector>& ia, bool resize_ok) const +{ + return index (ia, resize_ok, resize_fill_value ()); +} + +template <typename T, typename Alloc> void Array<T, Alloc>::assign (const octave::idx_vector& i, const Array<T, Alloc>& rhs, const T& rfv) { @@ -1394,6 +1408,14 @@ } } +template <typename T, typename Alloc> +void +Array<T, Alloc>::assign (const Array<octave::idx_vector>& ia, + const Array<T, Alloc>& rhs) +{ + assign (ia, rhs, resize_fill_value ()); +} + /* %!shared a %! a = [1 2; 3 4];
--- a/liboctave/array/Array.h Fri Feb 02 17:20:38 2024 +0100 +++ b/liboctave/array/Array.h Fri Feb 02 17:15:09 2024 +0100 @@ -123,6 +123,9 @@ //! - string_vector: Array<std::string> with 1 column //! - Cell: Array<octave_value>, equivalent to an Octave cell. +// forward declare template with visibility attributes +template <typename T, typename Alloc> class OCTARRAY_API Array; + template <typename T, typename Alloc> class OCTARRAY_TEMPLATE_API Array { @@ -511,11 +514,8 @@ OCTARRAY_API octave_idx_type compute_index (const Array<octave_idx_type>& ra_idx) const; - OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type - compute_index_unchecked (const Array<octave_idx_type>& ra_idx) const - { - return m_dimensions.compute_index (ra_idx.data (), ra_idx.numel ()); - } + OCTARRAY_API octave_idx_type + compute_index_unchecked (const Array<octave_idx_type>& ra_idx) const; // No checking, even for multiple references, ever. @@ -731,11 +731,8 @@ OCTARRAY_API Array<T, Alloc> index (const Array<octave::idx_vector>& ia, bool resize_ok, const T& rfv) const; - OCTARRAY_OVERRIDABLE_FUNC_API Array<T, Alloc> - index (const Array<octave::idx_vector>& ia, bool resize_ok) const - { - return index (ia, resize_ok, resize_fill_value ()); - } + OCTARRAY_API Array<T, Alloc> + index (const Array<octave::idx_vector>& ia, bool resize_ok) const; //@} //@{ @@ -760,11 +757,8 @@ OCTARRAY_API void assign (const Array<octave::idx_vector>& ia, const Array<T, Alloc>& rhs, const T& rfv); - OCTARRAY_OVERRIDABLE_FUNC_API void - assign (const Array<octave::idx_vector>& ia, const Array<T, Alloc>& rhs) - { - assign (ia, rhs, resize_fill_value ()); - } + OCTARRAY_API void + assign (const Array<octave::idx_vector>& ia, const Array<T, Alloc>& rhs); //@} //@{