Array::addArray

Hello

I’m experiencing a small problem when attempting to compile the following code under VS2008:

Array<CBusInfo*> biaStereoBuses;
ScopedPointer<CBusSourcesEnum> ptrEnum(m_pOwnerFrame->GetBusSourcesEnum());
BusType nBusType = BT_NONE;
if(ptrEnum != 0)
{
	CBusInfo* biaRetrieved[256];
	unsigned long uNbRetrieved = 0;
	nBusType = BT_STEREO_MIX;
	if(ptrEnum->Next(256, &biaRetrieved[0], &uNbRetrieved, &nBusType) &&
		 uNbRetrieved > 0)
	{
		biaStereoBuses.addArray(&biaRetrieved[0], (int)uNbRetrieved);
	}
	ptrEnum->Reset();
	uNbRetrieved = 0;
}

Basically, I retrieve a set of values through a basic C/C++ array of pointers (biaRetrieved), and then I want to put the retrieved values in a templated Juce Array object (biaStereoBuses) for easier access.
Juce Array class defines 2 different addArray(…) methods, and the one I need is the 1st one, [color=#FF0000]void addArray (const ElementType* elementsToAdd, int numElementsToAdd)[/color].
The problem is that the compiler attempts to use the [color=#FF0000]template void addArray (const OtherArrayType& arrayToAddFrom,int startIndex = 0, int numElementsToAdd = -1)[/color] rather than the [color=#FF0000]void addArray (const ElementType* elementsToAdd, int numElementsToAdd)[/color], which leads to the following error:

1>        juce_amalgamated.h(2277) : error C2825: 'OtherArrayType': must be a class or namespace when followed by '::'
1>        meteringclientpanel.cpp(212) : see reference to function template instantiation 'void juce::Array<ElementType>::addArray<const CBusInfo**>(const OtherArrayType &,int,int)' being compiled
1>        with
1>        [
1>            ElementType=CBusInfo *,
1>            OtherArrayType=const CBusInfo **
1>        ]

Compiler assumes the OtherArrayType to be CBusInfo**, and thus fails on the [color=#FF0000]const typename OtherArrayType::ScopedLockType lock1 (arrayToAddFrom.getLock());[/color] piece of code.
Any idea? am I doing something wrong? I know how to force the compiler to use the templated method, but in this case I just want it to use the non-templated version of addArray(…)

Thanks

Cheers

You should cast biaRetrieved (because it’s not const (CBusInfo*) * but CBusInfo*[256] so the template is a better match for the compiler).

Thanks for the advise. Actually, such cast does not work since compiler will interpret this syntax as a function pointer, but using a typedef for CBusInfo* does the job.

Problem solved,

Thanks

Cheers