@@ -111,128 +111,291 @@ namespace winrt::impl
111111 struct reference_traits
112112 {
113113 static auto make (T const & value) { return winrt::make<impl::reference<T>>(value); }
114+ using itf = Windows::Foundation::IReference<T>;
114115 };
115116
116117 template <>
117118 struct reference_traits <uint8_t >
118119 {
119120 static auto make (uint8_t value) { return Windows::Foundation::PropertyValue::CreateUInt8 (value); }
121+ using itf = Windows::Foundation::IReference<uint8_t >;
120122 };
121123
122124 template <>
123125 struct reference_traits <uint16_t >
124126 {
125127 static auto make (uint16_t value) { return Windows::Foundation::PropertyValue::CreateUInt16 (value); }
128+ using itf = Windows::Foundation::IReference<uint16_t >;
126129 };
127130
128131 template <>
129132 struct reference_traits <int16_t >
130133 {
131134 static auto make (int16_t value) { return Windows::Foundation::PropertyValue::CreateInt16 (value); }
135+ using itf = Windows::Foundation::IReference<int16_t >;
132136 };
133137
134138 template <>
135139 struct reference_traits <uint32_t >
136140 {
137141 static auto make (uint32_t value) { return Windows::Foundation::PropertyValue::CreateUInt32 (value); }
142+ using itf = Windows::Foundation::IReference<uint32_t >;
138143 };
139144
140145 template <>
141146 struct reference_traits <int32_t >
142147 {
143148 static auto make (int32_t value) { return Windows::Foundation::PropertyValue::CreateInt32 (value); }
149+ using itf = Windows::Foundation::IReference<int32_t >;
144150 };
145151
146152 template <>
147153 struct reference_traits <uint64_t >
148154 {
149155 static auto make (uint64_t value) { return Windows::Foundation::PropertyValue::CreateUInt64 (value); }
156+ using itf = Windows::Foundation::IReference<uint64_t >;
150157 };
151158
152159 template <>
153160 struct reference_traits <int64_t >
154161 {
155162 static auto make (int64_t value) { return Windows::Foundation::PropertyValue::CreateInt64 (value); }
163+ using itf = Windows::Foundation::IReference<int64_t >;
156164 };
157165
158166 template <>
159167 struct reference_traits <float >
160168 {
161169 static auto make (float value) { return Windows::Foundation::PropertyValue::CreateSingle (value); }
170+ using itf = Windows::Foundation::IReference<float >;
162171 };
163172
164173 template <>
165174 struct reference_traits <double >
166175 {
167176 static auto make (double value) { return Windows::Foundation::PropertyValue::CreateDouble (value); }
177+ using itf = Windows::Foundation::IReference<double >;
168178 };
169179
170180 template <>
171181 struct reference_traits <char16_t >
172182 {
173183 static auto make (char16_t value) { return Windows::Foundation::PropertyValue::CreateChar16 (value); }
184+ using itf = Windows::Foundation::IReference<char16_t >;
174185 };
175186
176187 template <>
177188 struct reference_traits <bool >
178189 {
179190 static auto make (bool value) { return Windows::Foundation::PropertyValue::CreateBoolean (value); }
191+ using itf = Windows::Foundation::IReference<bool >;
180192 };
181193
182194 template <>
183195 struct reference_traits <hstring>
184196 {
185197 static auto make (hstring const & value) { return Windows::Foundation::PropertyValue::CreateString (value); }
198+ using itf = Windows::Foundation::IReference<hstring>;
186199 };
187200
188201 template <>
189202 struct reference_traits <Windows::Foundation::IInspectable>
190203 {
191204 static auto make (Windows::Foundation::IInspectable const & value) { return Windows::Foundation::PropertyValue::CreateInspectable (value); }
205+ using itf = Windows::Foundation::IInspectable;
192206 };
193207
194208 template <>
195209 struct reference_traits <guid>
196210 {
197211 static auto make (guid const & value) { return Windows::Foundation::PropertyValue::CreateGuid (value); }
212+ using itf = Windows::Foundation::IReference<guid>;
198213 };
199214
200215#ifdef WINRT_IMPL_IUNKNOWN_DEFINED
201216 template <>
202217 struct reference_traits <GUID>
203218 {
204219 static auto make (GUID const & value) { return Windows::Foundation::PropertyValue::CreateGuid (value); }
220+ using itf = Windows::Foundation::IReference<guid>;
205221 };
206222#endif
207223
208224 template <>
209225 struct reference_traits <Windows::Foundation::DateTime>
210226 {
211227 static auto make (Windows::Foundation::DateTime value) { return Windows::Foundation::PropertyValue::CreateDateTime (value); }
228+ using itf = Windows::Foundation::IReference<Windows::Foundation::DateTime>;
212229 };
213230
214231 template <>
215232 struct reference_traits <Windows::Foundation::TimeSpan>
216233 {
217234 static auto make (Windows::Foundation::TimeSpan value) { return Windows::Foundation::PropertyValue::CreateTimeSpan (value); }
235+ using itf = Windows::Foundation::IReference<Windows::Foundation::TimeSpan>;
218236 };
219237
220238 template <>
221239 struct reference_traits <Windows::Foundation::Point>
222240 {
223241 static auto make (Windows::Foundation::Point const & value) { return Windows::Foundation::PropertyValue::CreatePoint (value); }
242+ using itf = Windows::Foundation::IReference<Windows::Foundation::Point>;
224243 };
225244
226245 template <>
227246 struct reference_traits <Windows::Foundation::Size>
228247 {
229248 static auto make (Windows::Foundation::Size const & value) { return Windows::Foundation::PropertyValue::CreateSize (value); }
249+ using itf = Windows::Foundation::IReference<Windows::Foundation::Size>;
230250 };
231251
232252 template <>
233253 struct reference_traits <Windows::Foundation::Rect>
234254 {
235255 static auto make (Windows::Foundation::Rect const & value) { return Windows::Foundation::PropertyValue::CreateRect (value); }
256+ using itf = Windows::Foundation::IReference<Windows::Foundation::Rect>;
257+ };
258+
259+ template <>
260+ struct reference_traits <com_array<uint8_t >>
261+ {
262+ static auto make (array_view<uint8_t const > const & value) { return Windows::Foundation::PropertyValue::CreateUInt8Array (value); }
263+ using itf = Windows::Foundation::IReferenceArray<uint8_t >;
264+ };
265+
266+ template <>
267+ struct reference_traits <com_array<int16_t >>
268+ {
269+ static auto make (array_view<int16_t const > const & value) { return Windows::Foundation::PropertyValue::CreateInt16Array (value); }
270+ using itf = Windows::Foundation::IReferenceArray<int16_t >;
271+ };
272+
273+ template <>
274+ struct reference_traits <com_array<uint16_t >>
275+ {
276+ static auto make (array_view<uint16_t const > const & value) { return Windows::Foundation::PropertyValue::CreateUInt16Array (value); }
277+ using itf = Windows::Foundation::IReferenceArray<uint16_t >;
278+ };
279+
280+ template <>
281+ struct reference_traits <com_array<int32_t >>
282+ {
283+ static auto make (array_view<int32_t const > const & value) { return Windows::Foundation::PropertyValue::CreateInt32Array (value); }
284+ using itf = Windows::Foundation::IReferenceArray<int32_t >;
285+ };
286+
287+ template <>
288+ struct reference_traits <com_array<uint32_t >>
289+ {
290+ static auto make (com_array<uint32_t > const & value) { return Windows::Foundation::PropertyValue::CreateUInt32Array (value); }
291+ using itf = Windows::Foundation::IReferenceArray<uint32_t >;
292+ };
293+
294+ template <>
295+ struct reference_traits <com_array<int64_t >>
296+ {
297+ static auto make (array_view<int64_t const > const & value) { return Windows::Foundation::PropertyValue::CreateInt64Array (value); }
298+ using itf = Windows::Foundation::IReferenceArray<int64_t >;
299+ };
300+
301+ template <>
302+ struct reference_traits <com_array<uint64_t >>
303+ {
304+ static auto make (array_view<uint64_t const > const & value) { return Windows::Foundation::PropertyValue::CreateUInt64Array (value); }
305+ using itf = Windows::Foundation::IReferenceArray<uint64_t >;
306+ };
307+
308+ template <>
309+ struct reference_traits <com_array<float >>
310+ {
311+ static auto make (array_view<float const > const & value) { return Windows::Foundation::PropertyValue::CreateSingleArray (value); }
312+ using itf = Windows::Foundation::IReferenceArray<float >;
313+ };
314+
315+ template <>
316+ struct reference_traits <com_array<double >>
317+ {
318+ static auto make (array_view<double const > const & value) { return Windows::Foundation::PropertyValue::CreateDoubleArray (value); }
319+ using itf = Windows::Foundation::IReferenceArray<double >;
320+ };
321+
322+ template <>
323+ struct reference_traits <com_array<char16_t >>
324+ {
325+ static auto make (array_view<char16_t const > const & value) { return Windows::Foundation::PropertyValue::CreateChar16Array (value); }
326+ using itf = Windows::Foundation::IReferenceArray<char16_t >;
327+ };
328+
329+ template <>
330+ struct reference_traits <com_array<bool >>
331+ {
332+ static auto make (array_view<bool const > const & value) { return Windows::Foundation::PropertyValue::CreateBooleanArray (value); }
333+ using itf = Windows::Foundation::IReferenceArray<bool >;
334+ };
335+
336+ template <>
337+ struct reference_traits <com_array<hstring>>
338+ {
339+ static auto make (array_view<hstring const > const & value) { return Windows::Foundation::PropertyValue::CreateStringArray (value); }
340+ using itf = Windows::Foundation::IReferenceArray<hstring>;
341+ };
342+
343+ template <>
344+ struct reference_traits <com_array<Windows::Foundation::IInspectable>>
345+ {
346+ static auto make (array_view<Windows::Foundation::IInspectable const > const & value) { return Windows::Foundation::PropertyValue::CreateInspectableArray (value); }
347+ using itf = Windows::Foundation::IReferenceArray<Windows::Foundation::IInspectable>;
348+ };
349+
350+ template <>
351+ struct reference_traits <com_array<guid>>
352+ {
353+ static auto make (array_view<guid const > const & value) { return Windows::Foundation::PropertyValue::CreateGuidArray (value); }
354+ using itf = Windows::Foundation::IReferenceArray<guid>;
355+ };
356+
357+ #ifdef WINRT_IMPL_IUNKNOWN_DEFINED
358+ template <>
359+ struct reference_traits <com_array<GUID>>
360+ {
361+ static auto make (array_view<GUID const > const & value) { return Windows::Foundation::PropertyValue::CreateGuidArray (reinterpret_cast <array_view<guid const > const &>(value)); }
362+ using itf = Windows::Foundation::IReferenceArray<guid>;
363+ };
364+ #endif
365+
366+ template <>
367+ struct reference_traits <com_array<Windows::Foundation::DateTime>>
368+ {
369+ static auto make (array_view<Windows::Foundation::DateTime const > const & value) { return Windows::Foundation::PropertyValue::CreateDateTimeArray (value); }
370+ using itf = Windows::Foundation::IReferenceArray<Windows::Foundation::DateTime>;
371+ };
372+
373+ template <>
374+ struct reference_traits <com_array<Windows::Foundation::TimeSpan>>
375+ {
376+ static auto make (array_view<Windows::Foundation::TimeSpan const > const & value) { return Windows::Foundation::PropertyValue::CreateTimeSpanArray (value); }
377+ using itf = Windows::Foundation::IReferenceArray<Windows::Foundation::TimeSpan>;
378+ };
379+
380+ template <>
381+ struct reference_traits <com_array<Windows::Foundation::Point>>
382+ {
383+ static auto make (array_view<Windows::Foundation::Point const > const & value) { return Windows::Foundation::PropertyValue::CreatePointArray (value); }
384+ using itf = Windows::Foundation::IReferenceArray<Windows::Foundation::Point>;
385+ };
386+
387+ template <>
388+ struct reference_traits <com_array<Windows::Foundation::Size>>
389+ {
390+ static auto make (array_view<Windows::Foundation::Size const > const & value) { return Windows::Foundation::PropertyValue::CreateSizeArray (value); }
391+ using itf = Windows::Foundation::IReferenceArray<Windows::Foundation::Size>;
392+ };
393+
394+ template <>
395+ struct reference_traits <com_array<Windows::Foundation::Rect>>
396+ {
397+ static auto make (array_view<Windows::Foundation::Rect const > const & value) { return Windows::Foundation::PropertyValue::CreateRectArray (value); }
398+ using itf = Windows::Foundation::IReferenceArray<Windows::Foundation::Rect>;
236399 };
237400}
238401
@@ -282,14 +445,16 @@ namespace winrt::impl
282445 }
283446 }
284447#ifdef WINRT_IMPL_IUNKNOWN_DEFINED
285- else if constexpr (std::is_same_v<T, GUID>)
448+ else if constexpr (std::is_same_v<T, com_array< GUID> >)
286449 {
287- return value.template as <Windows::Foundation::IReference<guid>>().Value ();
450+ T result;
451+ reinterpret_cast <com_array<guid>&>(result) = value.template as <typename impl::reference_traits<T>::itf>().Value ();
452+ return result;
288453 }
289454#endif
290455 else
291456 {
292- return value.template as <Windows::Foundation::IReference <T>>().Value ();
457+ return value.template as <typename impl::reference_traits <T>::itf >().Value ();
293458 }
294459 }
295460
@@ -309,17 +474,19 @@ namespace winrt::impl
309474 }
310475 }
311476#ifdef WINRT_IMPL_IUNKNOWN_DEFINED
312- else if constexpr (std::is_same_v<T, GUID>)
477+ else if constexpr (std::is_same_v<T, com_array< GUID> >)
313478 {
314- if (auto temp = value.template try_as <Windows::Foundation::IReference<guid> >())
479+ if (auto temp = value.template try_as <typename impl::reference_traits<T>::itf >())
315480 {
316- return temp.Value ();
481+ T result;
482+ reinterpret_cast <com_array<guid>&>(result) = temp.Value ();
483+ return result;
317484 }
318485 }
319486#endif
320487 else
321488 {
322- if (auto temp = value.template try_as <Windows::Foundation::IReference <T>>())
489+ if (auto temp = value.template try_as <typename impl::reference_traits <T>::itf >())
323490 {
324491 return temp.Value ();
325492 }
@@ -416,5 +583,5 @@ WINRT_EXPORT namespace winrt
416583 }
417584
418585 template <typename T>
419- using optional = Windows::Foundation::IReference <T>;
586+ using optional = typename impl::reference_traits <T>::itf ;
420587}
0 commit comments