You can create a MATLAB® interface to shared libraries based on C++98 and commonly occurring C++11 features. However, if a library contains the following data types or language features, then the functionality is not included in the MATLAB interface to the library. You might be able to include this functionality by creating a wrapper header file. For more information, see C++ Limitation Workaround Examples.
Any type with a size greater than 64 bits, for example long double
void *
Arrays of character types (wchar_t
, char16_t
, char32_t
)
Pointers or arrays of std::string
References to a pointer in a function
Pointers or references to enumerations
Reference data members
std
smart pointers other than std::shared_ptr
Static data members
**
pointers to primitive types, such as double**
. MATLAB supports **
pointers to custom classes used as function or method parameter types.
Multilevel pointers, such as type
***
Function pointer
Class templates with incomplete or no instantiations
union
These types defined in the std
namespace are supported. All other types in the std
namespace are not supported.
std::string
, std::wstring
, std::u16string
, std::u32string
std::vector
std::shared_ptr
If a library uses these data types, then the functionality is not included in the MATLAB interface to the library, and MATLAB displays messages like:
Did not add member 'methodName' to class 'ClassName' at HeaderFile.h:290. 'long double' is not a supported type.
To view these messages, use the 'Verbose'
option in the clibgen.generateLibraryDefinition
or clibgen.buildInterface
functions.
move
constructor
Overloaded operator functions
Unnamed namespaces and classes
Macro constants
Global variables
Variadic functions
Function templates with incomplete or no instantiations
Creating objects of classes in std
namespace, including custom
classes.
Smart pointer semantics. Only std::shared_ptr
is supported.
MATLAB does not support operator overloads, move semantics, and the member
functions in the class definition of the smart pointer which might restrict their
effectiveness. Instead, a std::shared_ptr<T>
behaves as type
T
in MATLAB. Type T
can be passed as input for
std::shared_ptr<T>
, and type T
is received as
output for std::shared_ptr<T>
.
Namespace aliases. Use original namespace name instead.
Certain class methods that have MATLAB names are not supported. These methods are eq
,
ne
, lt
, gt
,
le
, and ge
.
When you build a library containing these features or usage, MATLAB displays:
Warning: Some C++ language constructs in the header file are not supported and not imported.
Note
Saving C++ objects into a MAT-file is not supported.