C++: Capacity of variable length array

Hello, I’ve been experimenting with the C++ language output of nunavut.

I might have missed something, but I don’t see a way for an application to retrieve the maximum capacity of a variable length array from the generated types.

For example, for uavcan/primitive/Unstructured.1.0,

In the generated C type, the capacity is defined:
#define uavcan_primitive_Unstructured_1_0_value_ARRAY_CAPACITY_ 256U

A copy of the C++ type can be found here.

Is there a way to get the capacity of value from the C++ type?

1 Like

I think this is not possible at the moment. @ASMik can you please confirm?

1 Like

Yes, currently this constant is not available. I think we should add it to generated C++. See this PR

1 Like

This depends on the C++ type you generate. The built-in VariableLengthArray has a public property max_size. If you use std::vector then we are missing this data and need to provide it. Let me look at the PR from @ASMik

1 Like