@@ -38,22 +38,27 @@ namespace ice
3838 ValueType* _data;
3939
4040 inline explicit Array (ice::Allocator& alloc) noexcept ;
41+ inline ~Array () noexcept ;
42+
4143 inline Array (Array&& other) noexcept ;
4244 inline Array (Array const & other) noexcept
4345 requires std::copy_constructible<Type>;
44- inline ~Array () noexcept ;
4546
4647 inline Array (
4748 ice::Allocator& alloc,
4849 ice::Span<Type const > values
4950 ) noexcept requires std::copy_constructible<Type>;
5051
51- // API Requirements Of: Container and Resizable Container
52- template <typename Self>
53- constexpr auto data (this Self& self) noexcept -> ice::container::ValuePtr<Self> { return self._data ; }
52+ inline auto operator =(Array&& other) noexcept -> Array&;
53+ inline auto operator =(Array const & other) noexcept -> Array&
54+ requires std::copy_constructible<Type>;
55+
56+ // API Requirements Of: Container
5457 constexpr auto size () const noexcept -> ice::ncount { return { _count, sizeof (ValueType) }; }
5558
5659 // API Requirements Of: Resizable Container
60+ template <typename Self>
61+ constexpr auto data (this Self& self) noexcept -> ice::container::ValuePtr<Self> { return self._data ; }
5762 constexpr auto capacity () const noexcept -> ice::ncount { return { _capacity, sizeof (ValueType) }; }
5863 constexpr void set_capacity (ice::ncount new_capacity) noexcept ;
5964 constexpr void resize (ice::ncount new_size) noexcept ;
@@ -65,8 +70,7 @@ namespace ice
6570 inline void push_back (ItemType&& item) noexcept ;
6671
6772 template <ice::concepts::IterableContainer ContainerT>
68- requires (std::convertible_to<ice::container::ValueType<ContainerT>, Type>
69- && std::is_constructible_v<Type, ice::container::ValueType<ContainerT>>)
73+ requires (ice::concepts::CompatibleContainer<Type, ContainerT>)
7074 inline void push_back (ContainerT const & other) noexcept ;
7175
7276 inline void pop_back (ice::ncount count = 1_count) noexcept ;
@@ -75,19 +79,13 @@ namespace ice
7579 constexpr auto data_view (this Array const & self) noexcept -> ice::Data;
7680 constexpr auto memory_view (this Array& self) noexcept -> ice::Memory;
7781
78- inline auto operator =(Array&& other) noexcept -> Array&;
79- inline auto operator =(Array const & other) noexcept -> Array&
80- requires std::copy_constructible<Type>;
81-
82+ // Operators and implicit conversions
8283 inline operator ice::Span<Type>() noexcept ;
8384 inline operator ice::Span<Type const >() const noexcept ;
8485 };
8586
8687 template <typename Type, ice::ContainerLogic Logic>
87- auto data_view (ice::Array<Type, Logic> const & arr) noexcept -> ice::Data
88- {
89- return arr.data_view ();
90- }
88+ auto data_view (ice::Array<Type, Logic> const & arr) noexcept -> ice::Data = delete;
9189
9290 template <typename Type, ice::ContainerLogic Logic>
9391 inline Array<Type, Logic>::Array(ice::Allocator& alloc) noexcept
@@ -97,6 +95,17 @@ namespace ice
9795 , _data{ nullptr }
9896 { }
9997
98+ template <typename Type, ice::ContainerLogic Logic>
99+ inline Array<Type, Logic>::~Array () noexcept
100+ {
101+ if constexpr (Logic == ContainerLogic::Complex)
102+ {
103+ ice::mem_destruct_n_at (_data, _count);
104+ }
105+
106+ _allocator->deallocate (memory_view ());
107+ }
108+
100109 template <typename Type, ice::ContainerLogic Logic>
101110 inline Array<Type, Logic>::Array(Array&& other) noexcept
102111 : _allocator{ other._allocator }
@@ -137,24 +146,12 @@ namespace ice
137146 }
138147 }
139148
140- template <typename Type, ice::ContainerLogic Logic>
141- inline Array<Type, Logic>::~Array () noexcept
142- {
143- if constexpr (Logic == ContainerLogic::Complex)
144- {
145- ice::mem_destruct_n_at (_data, _count);
146- }
147-
148- _allocator->deallocate (memory_view ());
149- }
150-
151149 template <typename Type, ice::ContainerLogic Logic>
152150 inline Array<Type, Logic>::Array(
153151 ice::Allocator& alloc,
154152 ice::Span<Type const > values
155- ) noexcept
156- requires std::copy_constructible<Type>
157- : _allocator{ &alloc }
153+ ) noexcept requires std::copy_constructible<Type>
154+ : _allocator{ &alloc }
158155 , _capacity{ 0 }
159156 , _count{ 0 }
160157 , _data{ nullptr }
@@ -228,18 +225,6 @@ namespace ice
228225 return *this ;
229226 }
230227
231- template <typename Type, ice::ContainerLogic Logic>
232- inline Array<Type, Logic>::operator ice::Span<Type>() noexcept
233- {
234- return Span{ _data, _count };
235- }
236-
237- template <typename Type, ice::ContainerLogic Logic>
238- inline Array<Type, Logic>::operator ice::Span<Type const >() const noexcept
239- {
240- return Span{ _data, _count };
241- }
242-
243228 template <typename Type, ice::ContainerLogic Logic>
244229 inline constexpr void ice::Array<Type, Logic>::set_capacity(ice::ncount new_capacity) noexcept
245230 {
@@ -349,8 +334,7 @@ namespace ice
349334
350335 template <typename Type, ice::ContainerLogic Logic>
351336 template <ice::concepts::IterableContainer ContainerT>
352- requires (std::convertible_to<ice::container::ValueType<ContainerT>, Type>
353- && std::is_constructible_v<Type, ice::container::ValueType<ContainerT>>)
337+ requires (ice::concepts::CompatibleContainer<Type, ContainerT>)
354338 inline void ice::Array<Type, Logic>::push_back(ContainerT const & other) noexcept
355339 {
356340 ice::ncount const current_size = size ();
@@ -408,5 +392,17 @@ namespace ice
408392 };
409393 }
410394
395+ template <typename Type, ice::ContainerLogic Logic>
396+ inline Array<Type, Logic>::operator ice::Span<Type>() noexcept
397+ {
398+ return Span{ _data, _count };
399+ }
400+
401+ template <typename Type, ice::ContainerLogic Logic>
402+ inline Array<Type, Logic>::operator ice::Span<Type const >() const noexcept
403+ {
404+ return Span{ _data, _count };
405+ }
406+
411407
412408} // namespace ice
0 commit comments