@@ -77,6 +77,9 @@ namespace xt
7777
7878 void swap (self_type& rhs) noexcept ;
7979
80+ template <class P >
81+ void reset_data (P&& data, size_type size) noexcept ;
82+
8083 private:
8184
8285 pointer p_data;
@@ -117,6 +120,9 @@ namespace xt
117120
118121 void swap (self_type& rhs) noexcept ;
119122
123+ template <class P , class DT >
124+ void reset_data (P&& data, size_type size, DT&& destruct) noexcept ;
125+
120126 private:
121127
122128 pointer p_data;
@@ -168,6 +174,9 @@ namespace xt
168174
169175 void swap (self_type& rhs) noexcept ;
170176
177+ template <class P >
178+ void reset_data (P&& data, size_type size, const allocator_type& alloc = allocator_type()) noexcept ;
179+
171180 private:
172181
173182 xtl::xclosure_wrapper<CP> m_data;
@@ -177,7 +186,7 @@ namespace xt
177186 };
178187
179188 // Workaround for MSVC2015: using void_t results in some
180- // template instantiation caching that leads to wrong
189+ // template instantiation caching that leads to wrong
181190 // type deduction later in xfunction.
182191 template <class T >
183192 struct msvc2015_void
@@ -393,6 +402,7 @@ namespace xt
393402 using base_type::resize;
394403 using base_type::data;
395404 using base_type::swap;
405+ using base_type::reset_data;
396406 };
397407
398408 template <class CP , class O , class A >
@@ -421,7 +431,7 @@ namespace xt
421431 using difference_type = std::common_type_t <typename traits::difference_type,
422432 typename const_traits::difference_type>;
423433 using size_type = std::make_unsigned_t <difference_type>;
424-
434+
425435 using iterator = I;
426436 using const_iterator = CI;
427437 using reverse_iterator = std::reverse_iterator<iterator>;
@@ -440,7 +450,7 @@ namespace xt
440450 using allocator_type = std::allocator<value_type>;
441451 using size_type = typename base_type::size_type;
442452 using iterator = typename base_type::iterator;
443- using const_iterator = typename base_type::const_iterator;
453+ using const_iterator = typename base_type::const_iterator;
444454 using temporary_type = uvector<value_type, allocator_type>;
445455
446456 xiterator_adaptor () = default ;
@@ -459,12 +469,12 @@ namespace xt
459469
460470 size_type size () const noexcept ;
461471 void resize (size_type size);
462-
472+
463473 iterator data () noexcept ;
464474 const_iterator data () const noexcept ;
465475
466476 void swap (self_type& rhs) noexcept ;
467-
477+
468478 private:
469479
470480 I m_it;
@@ -523,7 +533,7 @@ namespace xt
523533 using allocator_type = std::allocator<value_type>;
524534 using size_type = typename base_type::size_type;
525535 using iterator = typename base_type::iterator;
526- using const_iterator = typename base_type::const_iterator;
536+ using const_iterator = typename base_type::const_iterator;
527537 using temporary_type = uvector<value_type, allocator_type>;
528538
529539 xiterator_owner_adaptor (C&& c);
@@ -541,7 +551,7 @@ namespace xt
541551
542552 size_type size () const noexcept ;
543553 void resize (size_type size);
544-
554+
545555 iterator data () noexcept ;
546556 const_iterator data () const noexcept ;
547557
@@ -658,6 +668,14 @@ namespace xt
658668 swap (p_data, rhs.p_data );
659669 swap (m_size, rhs.m_size );
660670 }
671+
672+ template <class CP , class A >
673+ template <class P >
674+ inline void xbuffer_storage<CP, A>::reset_data(P&& data, size_type size) noexcept
675+ {
676+ p_data = std::forward<P>(data);
677+ m_size = size;
678+ }
661679 }
662680
663681 /* ***************************************
@@ -767,6 +785,14 @@ namespace xt
767785 swap (m_size, rhs.m_size );
768786 swap (m_allocator, rhs.m_allocator );
769787 }
788+
789+ template <class CP , class A >
790+ template <class P >
791+ inline void xbuffer_owner_storage<CP, A>::reset_data(P&& data, size_type size, const allocator_type& alloc) noexcept
792+ {
793+ xbuffer_owner_storage<CP, A> tmp (std::forward<P>(data), size, alloc);
794+ this ->swap (tmp);
795+ }
770796 }
771797
772798 /* ***************************************
@@ -793,7 +819,7 @@ namespace xt
793819 {
794820 if (m_size != size)
795821 {
796- XTENSOR_THROW (std::runtime_error, " xbuffer_storage not resizable " );
822+ XTENSOR_THROW (std::runtime_error, " xbuffer_storage not resizeable " );
797823 }
798824 }
799825
@@ -816,6 +842,15 @@ namespace xt
816842 swap (m_size, rhs.m_size );
817843 swap (m_destruct, rhs.m_destruct );
818844 }
845+
846+ template <class CP , class D >
847+ template <class P , class DT >
848+ void xbuffer_smart_pointer<CP, D>::reset_data(P&& data, size_type size, DT&& destruct) noexcept
849+ {
850+ p_data = std::forward<P>(data);
851+ m_size = size;
852+ m_destruct = destruct;
853+ }
819854 }
820855
821856 /* **************************************
@@ -1020,7 +1055,7 @@ namespace xt
10201055 /* ***********************************
10211056 * xiterator_adaptor implementation *
10221057 ************************************/
1023-
1058+
10241059 template <class I , class CI >
10251060 inline xiterator_adaptor<I, CI>::xiterator_adaptor(I it, CI cit, size_type size)
10261061 : m_it(it), m_cit(cit), m_size(size)
@@ -1040,7 +1075,7 @@ namespace xt
10401075 {
10411076 return (*this = rhs);
10421077 }
1043-
1078+
10441079 template <class I , class CI >
10451080 inline auto xiterator_adaptor<I, CI>::size() const noexcept -> size_type
10461081 {
@@ -1052,7 +1087,7 @@ namespace xt
10521087 {
10531088 if (m_size != size)
10541089 {
1055- XTENSOR_THROW (std::runtime_error, " xiterator_adaptor not resizable " );
1090+ XTENSOR_THROW (std::runtime_error, " xiterator_adaptor not resizeable " );
10561091 }
10571092 }
10581093
@@ -1076,7 +1111,7 @@ namespace xt
10761111 swap (m_cit, rhs.m_cit );
10771112 swap (m_size, rhs.m_size );
10781113 }
1079-
1114+
10801115 template <class I , class CI >
10811116 inline void swap (xiterator_adaptor<I, CI>& lhs,
10821117 xiterator_adaptor<I, CI>& rhs) noexcept
@@ -1087,7 +1122,7 @@ namespace xt
10871122 /* *****************************************
10881123 * xiterator_owner_adaptor implementation *
10891124 ******************************************/
1090-
1125+
10911126 template <class C , class IG >
10921127 inline xiterator_owner_adaptor<C, IG>::xiterator_owner_adaptor(C&& c)
10931128 : m_container(std::move(c))
@@ -1148,10 +1183,10 @@ namespace xt
11481183 {
11491184 if (m_size != size)
11501185 {
1151- XTENSOR_THROW (std::runtime_error, " xiterator_owner_adaptor not resizable " );
1186+ XTENSOR_THROW (std::runtime_error, " xiterator_owner_adaptor not resizeable " );
11521187 }
11531188 }
1154-
1189+
11551190 template <class C , class IG >
11561191 inline auto xiterator_owner_adaptor<C, IG>:: data() noexcept -> iterator
11571192 {
0 commit comments