4

I have an issue with using STL features with my UE4 project.

Intellisense is showing an error with its red line and isn't understanding what I'm attempting to write.

I use VS 2017 and have also downloaded the Unreal development settings.

I've tested the STL features with a blank project using the same IDE and it works fine there with no intellisense issues.

I assume that I'm missing some kind of special setting to do with Unreal Engine but I have no idea what it is and can't seem to find anything in their documentation.

Thanks

#include <vector>

#include "CoreMinimal.h"
#include "Interactable.h"
#include "Hand.generated.h"

class Card;

UCLASS()
class SKYLINE_API AHand : public AInteractable
{
    GENERATED_BODY()

public:

    void PlayCard();
    void DiscardCard();

private:

    std::vector<Card*> m_vpCards;

};
jckTol
  • 41
  • 1
  • 3

2 Answers2

3

Unreal Engine uses its own data structure rather than standard template library for compatibility and portability reason. Check this post by Kaiserludi for the detailed reasoning: https://forums.unrealengine.com/development-discussion/c-gameplay-programming/46700-why-doesn-t-ue-utilize-stl-containers

For vector you should use TArray: https://api.unrealengine.com/INT/API/Runtime/Core/Containers/TArray/index.html

Also when declaring fields of type not directly from Unreal Source, you should always declare them UPROPERTY() or else the engine with garbage collect its memory without you even knowing.

If you want to really use std::vector, someone by the name feixuwu utilized it on his/her websocket. You can check out the code here: https://github.com/feixuwu/UEWebsocket

0

Delete the saved , binaries and intermediate folders then right click on your Unreal project file and select generate VS project files and then open your project . Hope this helps as it worked for me.

LumbusterTick
  • 1,067
  • 10
  • 21