AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Module Coding (https://forums.alliedmods.net/forumdisplay.php?f=9)
-   -   [AMTL] Is there any way to clone a ke::Vector? (https://forums.alliedmods.net/showthread.php?t=311816)

11922911 11-03-2018 17:10

[AMTL] Is there any way to clone a ke::Vector?
 
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>::o 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>::o perator ='
1> amxmodx\modules\waypoint\Waypoint.h(13): note: see declaration of 'ke::Vector<int,ke::SystemAllocatorPolicy>'

klippy 11-04-2018 07:13

Re: [AMTL] Is there any way to clone a ke::Vector?
 
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



All times are GMT -4. The time now is 07:43.

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