Error Utility

内容表

Macros

These macros are used to automatically check the given condition and to return an error object if the condition is not met:

另请参阅 Error Types .

// This function checks the given arguments and returns an error if they do not match.

//---------------------------------------------------------------------------------------- // This functions adds the values stored in the second array to the values stored in the first array. // Both arrays must have the same size. // @param[in, out] arrayA The first array. It will contain the result values. // @param[in] arrayB The second array. // @return maxon::OK on success. //---------------------------------------------------------------------------------------- static maxon::Result<void> AddArrays( maxon::BaseArray<maxon::Int> & arrayA, maxon::BaseArray<maxon::Int> & arrayB) { iferr_scope ;

// check arguments CheckArgument (arrayA. GetCount () == arrayB. GetCount (), "Array sizes do not match." );

// add numbers

const maxon::Int size = arrayA. GetCount ();
for ( maxon::Int i = 0; i < size; ++i) arrayA[i] = arrayA[i] + arrayB[i]; return maxon::OK ; }

延伸阅读

maxon::OK
return OK
定义: apibase.h:2532
maxon::BaseArray
定义: basearray.h:366
maxon::Result< void >
maxon::BaseArray::GetCount
MAXON_ATTRIBUTE_FORCE_INLINE Int GetCount() const
定义: basearray.h:527
maxon::Int
Int64 Int
signed 32/64 bit int, size depends on the platform
定义: apibase.h:184
iferr_scope
#define iferr_scope
定义: resultbase.h:1343
CheckArgument
#define CheckArgument(condition,...)
定义: errorbase.h:478

Copyright  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1