Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

What are the required member functions for using TArrays?

I have a C++ class I am using quite extensively that inherits from nothing (chose none in the GUI). This class is just a data class and will not be placed in the world at any point. At some point I placed this class in a TArray and attempted to use TArray::RemoveSingle. This led to the following error:

Error C2678 binary '==': no operator found which takes a left-hand operand of type 'const Quad' (or there is no acceptable conversion) Array.h 992

I assumed this means "You don't have a == operator. How do I find something?" So I overloaded operator== and I was right. But this got me thinking, there are probably other scenarios that my class is missing that I am not thinking of. Do I need a < operator for sorting? Do I need a toString? Since my class doesn't inherit from anything, I do not have virtual functions to override. How can I know what functions I should make to ensure future classes behave as expected and don't throw unexpected compiler errors?

Product Version: UE 4.12
more ▼

asked Aug 24 '16 at 10:40 PM in C++ Programming

avatar image

58 13 12 19

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Yes, you need to make all operators because compiler don't know what to do with data in the class if you don't describe it. And yes oyu need < for sorting.

Also if you want class that just holds data i recomand you to make struct insted of class, this way it will be compatible with reflection system (if you use USTRUCT() and UPROPERTY()) making things a lot easier in editor

more ▼

answered Aug 24 '16 at 11:56 PM

avatar image

37.3k 936 172 1117

avatar image Zamithal Aug 25 '16 at 01:29 AM

All operators is a lot of operators. I really don't think I am going to need to overload a logical and operator or a subscript operator in order to use a function belonging to the TArray. I was just wondering if there was a "Your class should have at least these functions" somewhere in unreal's documentation.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question