Commit e520b9b
authored
[Utility][Container] Support non-nullable types in Array::Map (#17094)
[Container] Support non-nullable types in Array::Map
Prior to this commit, the `Array::Map` member function could only be
applied to nullable object types. This was due to the internal use of
`U()` as the default value for initializing the output `ArrayNode`, where
`U` is the return type of the mapping function. This default
constructor is only available for nullable types, and would result in
a compile-time failure for non-nullable types.
This commit replaces `U()` with `ObjectRef()` in `Array::Map`,
removing this limitation. Since all items in the output array are
overwritten before returning to the calling scope, initializing the
output array with `ObjectRef()` does not violate type safety.1 parent a4f20f0 commit e520b9b
1 file changed
+12
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
827 | 827 | | |
828 | 828 | | |
829 | 829 | | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
830 | 835 | | |
831 | | - | |
| 836 | + | |
832 | 837 | | |
833 | 838 | | |
834 | 839 | | |
| |||
843 | 848 | | |
844 | 849 | | |
845 | 850 | | |
846 | | - | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
847 | 857 | | |
848 | 858 | | |
849 | 859 | | |
| |||
0 commit comments