UE4 C++ Able to use TArray but not TQueue

In UE4 I know how to create a class.
I’ve made many just haven’t had to use a queue until today.

Here’s an example of what I’m making to try to get a TQueue in a test class.

   #pragma once
   
   // include files

   #include "MyObject.generated.h"

   // forward declare classes
   class MySecondObject;
   
   UCLASS( ClassGroup=(Custom),meta=(BlueprintSpawnableComponent) )
   class MYGAME_API MyObject : public UObject
   {
      GENERATED_BODY()
   
   public:
    // add your constructors, ext
   
    // my vars

   };   

So here’s my problem.
How come I can add a container of TArray and it compiles fine
Example:

In the includes section I add

#include "Public/Containers/Array.h"

Under the vars section
I can add something like this this

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MySpecialClass")
TArray<MySecondObject*> m_Array;

The above compiles fine.

But if I use a TQueue which is what I need,

#include "Public/Containers/Queue.h"

and variable

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MySpecialClass")
TQueue<MySecondObject*> m_Queue;

I get a compile error of
error :
Unrecognized type ‘TQueue’ - type must be a UCLASS, USTRUCT or UENUM

I’m not understanding why this is occurring.

Your MySecondObject class is not UCLASS, or it’s not inherited from UObject, check your header of that class.

in the game engine code i see examples of them using ints floats ext in the TQueue no problem I also changed the logic just to test it and replaced my TQueue to be a TQueue< int32 >. This is identically done in the game engine.
Example
Engine\Plugins\Online\OnlineSubsystemUtils\Source\OnlineSubsystemUtils\Public\VoicePacketBuffer.h
And still this gives the same error.

TQueue cannot be a UPROPERTY. It will work fine if you just remove the property declaration above.

3 Likes