OwnedArrays in HashMap?


#1

Sorry if this is a silly question. Is it ok to have a HashMap with OwnedArrays as values? Such as:

It seems difficult to access an OwnedArray from this. I end up with something like this:

But the compiler warns with “Taking address of Temporary”. It all seems very wrong to do, so I’ve avoided it. But I do feel tempted sometimes, hence my curiosity. I’d imagine I need some lessons with c++ templates.


#2

No - a HashMap can only hold classes that have pass-by-value semantics, but an OwnedArray can’t be copied.