About Store Forum Documentation Contact
Donations:
327$/mo



Post Reply 
Memory container copy constructor
Author Message
AndrewBGS Offline
Member

Post: #1
Memory container copy constructor
This is my 3rd attempt to ask for help regarding creating an actual Object from a Memory container (Memx in my case). In my design I badly need the actual item and not just a reference, so I need this kind of code to work:

Memx <Item> items;
...
Item item = items[i];

This does not work, because apparently that container does not have a copy constructor, or at least that's the error I'm getting. I'd appreciate it A LOT if you could change this for the next version.
04-30-2013 08:36 AM
Find all posts by this user Quote this message in a reply
cmontiel Offline
Member

Post: #2
RE: Memory container copy constructor
Item item = items[i];

this line calls Item::operator=(Item &src) not the copy constructor of Memx. Have you defined the assignment operator ?

What error you get?

IRC: irc.freenode.net
Channel: #Esenthel
04-30-2013 11:39 AM
Find all posts by this user Quote this message in a reply
AndrewBGS Offline
Member

Post: #3
RE: Memory container copy constructor
No, I have not defined any operator. I assume it should be defined in the container class, which is inaccessible to me. These are the errors I get if I use that line:

error C2660: 'EE::Game::Obj::Obj': function does not take 1 arguments
This diagnostic occurred in the compiler generated function 'EE::Game::Item::Item(const EE::Game::Item &)'
error C2558: struct 'EE::Actor' : no copy constructor available or copy constructor is declared 'explicit'
This diagnostic occurred in the compiler generated function 'EE::Game::Item::Item(const EE::Game::Item &)'

//manually copy-pasting these errors makes me think of another feature request....

Sadly I have to leave tomorrow in holiday, but I'll get back as soon as I can and complain about not being able to get objects out of memx container.
(This post was last modified: 04-30-2013 12:31 PM by AndrewBGS.)
04-30-2013 12:31 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Memory container copy constructor
This is not an issue of memory containers, but because Game::Obj is not copyable (it won't be changed).

You can manually create new object and copy necessary parameters if you'd like to, there's no need for anything to be added from the engine side.
04-30-2013 12:40 PM
Find all posts by this user Quote this message in a reply
AndrewBGS Offline
Member

Post: #5
RE: Memory container copy constructor
Let's say I agree... how would I go about manually creating an identical object to the one in the container? I've tried that too, but my way didn't work; how should I do that?
04-30-2013 01:10 PM
Find all posts by this user Quote this message in a reply
Tottel Offline
Member

Post: #6
RE: Memory container copy constructor
Create a new Item object, copy the params one by one from items[i]
04-30-2013 06:28 PM
Find all posts by this user Quote this message in a reply
Post Reply