MeshLib Documentation
Loading...
Searching...
No Matches
MRVector.h File Reference
#include "MRMeshFwd.h"
#include "MRAffineXf.h"
#include "MRId.h"

Go to the source code of this file.

Macros

#define MR_VECTOR_CONCAT(a, b)   MR_VECTOR_CONCAT_( a, b )
 concat tokens
 
#define MR_VECTOR_CONCAT_(a, b)   a ## b
 
#define MR_VECTOR_LIKE_DECL(ClassName, Type)
 
#define MR_VECTOR_DECL(Type)   MR_VECTOR_LIKE_DECL( MR_VECTOR_CONCAT( Vector, Type ), Type )
 

Macro Definition Documentation

◆ MR_VECTOR_CONCAT

#define MR_VECTOR_CONCAT ( a,
b )   MR_VECTOR_CONCAT_( a, b )

concat tokens

◆ MR_VECTOR_CONCAT_

#define MR_VECTOR_CONCAT_ ( a,
b )   a ## b

◆ MR_VECTOR_DECL

#define MR_VECTOR_DECL ( Type)    MR_VECTOR_LIKE_DECL( MR_VECTOR_CONCAT( Vector, Type ), Type )

◆ MR_VECTOR_LIKE_DECL

#define MR_VECTOR_LIKE_DECL ( ClassName,
Type )
Value:
typedef struct MR_VECTOR_CONCAT( MR, ClassName ) \
{ \
MR_VECTOR_CONCAT( MR, Type )* data; \
size_t size; \
void* reserved1; \
} MR_VECTOR_CONCAT( MR, ClassName ); \
MRMESHC_API void MR_VECTOR_CONCAT( MR_VECTOR_CONCAT( mr, ClassName ), Invalidate )( MR_VECTOR_CONCAT( MR, ClassName )* ); \
MRMESHC_API void MR_VECTOR_CONCAT( MR_VECTOR_CONCAT( mr, ClassName ), Free )( MR_VECTOR_CONCAT( MR, ClassName )* ); \
MRMESHC_API MR_VECTOR_CONCAT( MR, ClassName )* MR_VECTOR_CONCAT( MR_VECTOR_CONCAT( mr, ClassName ), New )(void);
#define MRMESHC_API
Definition MRMeshC/MRMeshFwd.h:19
#define MR_VECTOR_CONCAT(a, b)
concat tokens
Definition MRMeshC/MRVector.h:10
Definition MRCameraOrientationPlugin.h:8

To simplify access to C++ array containers (aka std::vector), we use std::span-like structs to store a pointer to data and array length. There are two important notes about using these structs:

  • if a function returns a pointer to a vector-like struct, you must call mrVector*Free function

if any operation resizes the underlying vector, the data pointer might be invalidated; it's better to call mrVector*Invalidate to update the pointer after any operation with the vector