Raised This Month: $12 Target: $400
 3% 

[AMTL] Is there any way to clone a ke::Vector?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
11922911
Senior Member
Join Date: Dec 2011
Location: Yuen Long Country
Old 11-03-2018 , 17:10   [AMTL] Is there any way to clone a ke::Vector?
Reply With Quote #1

i have the following code:
PHP Code:
    ke::Vector<intab;
    
b.append(1);
    
b
but it doesn't compile in Visual Studio 2015...

i was using the amxmodx sdk from here

1>amxmodx\modules\waypoint\Waypoint.h(15): error C2248: 'ke::Vector<int,ke::SystemAllocatorPolicy>: perator =': cannot access private member declared in class 'ke::Vector<int,ke::SystemAllocatorPolicy>'
1> amxmodx\public\amtl\amtl/am-vector.h(221): note: see declaration of 'ke::Vector<int,ke::SystemAllocatorPolicy>: perator ='
1> amxmodx\modules\waypoint\Waypoint.h(13): note: see declaration of 'ke::Vector<int,ke::SystemAllocatorPolicy>'
__________________

Last edited by 11922911; 11-03-2018 at 17:11.
11922911 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-04-2018 , 07:13   Re: [AMTL] Is there any way to clone a ke::Vector?
Reply With Quote #2

You have to copy it manually with iteration, the copy constructor isn't implemented for ke::Vector.
However if your item type is simple and can be copied just by copying bits (for example has no copy constructor with side effects, like primitive types), you can just memcpy it.
Code:
#include <cstring>

ke::Vector<int> a, b;
b.append(1);

a.ensure(b.length()); // Ensure that the underlying buffer is big enough
memcpy(a.buffer(), b.buffer(), b.length() * sizeof(int)); // Copy
__________________
klippy is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:19.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode