Jump to content

'get' is not a member of 'Unigine::Internal::Hash<Policy,Counter>'


photo

Recommended Posts

Posted

Hello,

This code compiles and works (but creates an unnecessary temporary ViewTypeDef)

int viewtype = 1;
const auto& vt = ig->getConfig()->getViewTypes();
Log::message("%s\n", vt.value(viewtype).post_material.get());

But this one doesn't, with this error: 'get' is not a member of 'Unigine::Internal::Hash<Policy,Counter>'

int viewtype = 1;
const auto& vt = ig->getConfig()->getViewTypes();
Log::message("%s\n", vt.valueRef(viewtype).post_material.get());

 

	template<typename K>
	const Value &valueRef(const K &k) const
	{
		return Parent::get(k);
	}

What am I obviously missing? Thanks!

Posted

Hi, Stephane

Yes you are right, the method

template<typename K>
const Value &valueRef(const K &k) const
{
return Parent::get(k);
}

doesn't work. Apparently it was left in the codebase by mistake, and will be deleted soon.

 

But instead you can use another method

template<typename K>
const Value &valueRef(const K &k, const Value &value) const
{
return get(k, value);
}

This method works as it should, but in the additional parameter you need to pass the default expected value, since the return value is a reference, and if there is no object, then we cannot return null reference.

  • Thanks 1
×
×
  • Create New...