What does the first parenthesis do?
// TArray<struct FBatchedLine> BatchedLines; // declared in LineBatchComponent.h
new(BatchedLines) FBatchedLine(Start, End, Color, LifeTime, Thickness, DepthPriority);
The new operator reference says it is a placement_params
:
If placement_params are provided, they are passed to the allocation function as additional arguments
I suppose it creates the object directly at the end of the given array BatchedLines
, but I am not sure to understand fully how it works.
When are placement_params
useful?
Note
For those who have an access to the github UnrealEngine repo, here is the source file.
This is placement new syntax. It constructs an object of type FBatchedLine
at the memory pointed to by BatchedLines
with the constructor arguments (Start, End, Color, LifeTime, Thickness, DepthPriority)
. After the call, BatchedLines
can be used to reference the constructed object.
Informally, you could imagine invoking the constructor with BatchedLines
being this
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With