SOLVED HashMap with BaseArray as value

With R20 I had no problem using a HashMap with a BaseArray<Int32> as value. All compiling fine, and working as expected.
Porting that implementation to R19 (for users having not upgraded to R20), I encounter a compiler error, mentioning that the operator= cannot be accessed, since private.
Obviously, I had to replace the R20 HashMap::Insert for an R19 HashMap::Put and there seems to lie the problem

	// key is an integer and value an array of integers
	maxon::HashMap<Int32, maxon::BaseArray<Int32>> dataKeyValue;

	const Int32 key = 1;

	maxon::HashMap<Int32, maxon::BaseArray<Int32>>::Entry* e = dataKeyValue.FindEntry(key);
	if (e)
	{
		maxon::BaseArray<Int32>& values = e->GetValue();

		// ...
	}
	else
	{
		maxon::BaseArray<Int32> newValues;
		
		// ...
		
		dataKeyValue.Put(key, newValues);
	}

The compiler error:

error C2248: 'maxon::BaseArray<Bool,16,maxon::BASEARRAYFLAGS_0,maxon::DefaultAllocator>::operator =': cannot access private member declared in class 'maxon::BaseArray<Bool,16,maxon::BASEARRAYFLAGS_0,maxon::DefaultAllocator>'

Any hint what I could do in order to have the same functionality compiled in R19?
Thanks in advance.

Hi Daniel, thanks for reaching out us.

With regard to your question, the old HashMap::Put implementation does only support types which have a copy-assignment operator. But there’s the FindOrCreateEntry function which inserts an entry and default-initializes the value, then the value can be set later.

maxon::Bool created = false;

maxon::HashMap<Int32, maxon::BaseArray<Int32>>::Entry* e = dataKeyValue.FindOrCreateEntry(key, created);

if (!e)
        // error handling

if (created)
{
        maxon::BaseArray<Int32> newValues;
        // ...
        e->SetValue(std::move(newValues));
}

Let me know if it does work as expected.

Cheers, Riccardo

@r_gigante
Thanks for the headsup about FindOrCreateEntry.
Since Put does use that method internally, I didn't even consider about trying to use it, as I simply assumed it would have the same issue. Guess I was wrong about not trying it.

Problem solved.