Main Content

clibArray

Create MATLAB clib array for C++ library functions

Description

example

cArray = clibArray(elementTypeName,dimensions) creates a clib array, a MATLAB® object representing a C++ object of elementTypeName with C++ dimensions specified as [x1,...,xN]. If the C++ object is a primitive type, then cArray contains zero values. If the C++ object is a class-type, then MATLAB initializes cArray using the default constructor.

A MATLAB clib array can be defined only when the corresponding C++ native array or std::vector is used by supported C++ constructs — function arguments, function returns, and data members.

Alternatively, if the element type is a fundamental type, a user-defined class with a default constructor, or a standard string type, call the clib.array constructor. For example, for elementTypeName defined in libname:

cArray = clib.array.libname.elementTypeName(dimensions)

The memory of cArray is owned by MATLAB. To release the memory, call clibRelease.

To convert a MATLAB array to a C++ array, call clibConvertArray.

Examples

collapse all

Suppose that you have a library libname with a class myclass.

Create an empty array of five myclass objects.

myclassArray = clibArray('clib.libname.myclass',5);
class(myclassArray)
ans = 
    'clib.array.libname.myclass' 

Input Arguments

collapse all

C++ type, specified as a string or a character vector. For more information, see C++ to MATLAB Data Type Mapping. Supported types are:

MATLAB converts the names of fundamental C++ types to upper camel case. For example, elementTypeName for C++ type signed int is SignedInt.

The type is a fully qualified C++ type name. For example, if a library libname defines a class myclass, then elementTypeName is clib.libname.myclass.

Example: clib.libname.Double

Data Types: char | string

The number of elements in each dimension of the array, specified as integers [x1,...,xN].

Example: [2,3]

Introduced in R2020a