Expander: custom object?

Hi,

is it possible to pass a custom object on the buffer instead of arrays? Trying to do this:

struct MyValues {
	float mValue1;
	float mValue2;

	MyValues() : mValue1(1.0f), mValue2(2.0f) {
	}
};

std::array<MyValues, 2> leftMessages;

but when I connect the void*, it can’t cast:

leftExpander.producerMessage = leftMessages[0];
leftExpander.consumerMessage = leftMessages[1];

is it possible? What’s the best practice? I’ve some data which is not always “array of float” :slight_smile:

Thanks

Maybe &leftMessages[...]?

1 Like

Lol, what a idiot! Yes of course, I often forget that c/c++ compilers does “&” automatically when dealing with arrays (because in fact they are already “pointer”) :stuck_out_tongue_winking_eye: k_out_tongue:

Thanks, and sorry for this :slight_smile:

The method std::array::operator[](), which is what you call with the code lastMessages[0], returns the type MyValues& (a reference to the element stored in the std::array). If you take the address of a reference, you get a pointer to the element, which you can cast to void* and then back to MyValues* by the expander module.