The generated code for a UCLASS appears to require a default constructor for the class’ fields, which TCircularBuffer does not provide. I’m able to add a default constructor to the class to fix this problem, but it makes my code less portable, and users of standalone ue4 binaries aren’t able to make a fix like that. It’s not a huge pain since heap allocation would also solve this, but I’m curious what the intended use of TCircularBuffer is.
TCircularBuffer requires a capacity during construction. A parameter-less default constructor does not make sense for this class. If you’re writing a UCLASS that holds a TCircularBuffer, then you must specify a default constructor for your class that correctly initializes the buffer in its initialization list.
Use the GENERATED_BODY instead of GENERATED_UCLASS_BODY macro. For example:
UCLASS()
class UMyObject : public UObject
{
GENERATED_BODY()
public:
UMyObject()
: Buffer(128)
{ }
private:
TCircularBuffer<int32> Buffer;
};
I have vague memories of being unable to compile a scene component (which my class inherits from) with a default compiler, but in 4.7 and 4.9 the headers clearly show that’s fine. Thanks for the response!
I switched my class over to using a default constructor. However once I reverted CircularBuffer.h to remove the default constructor I added, the problem returned. My class is inherits from USceneComponent. Here’s what’s happening:
Unreal is generating a constructor for my class for hot reload which relies on default constructors for all of the fields. This is the detail I wasn’t remembering from before. I understand if the nature of the build tool makes this specific thing I’m trying to do impossible, but I wanted to bring it up in case it sounded like a bug.