Core: clone/pick refinements, heap refinements

git-svn-id: svn://ultimatepp.org/upp/trunk@13525 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2019-08-08 20:58:34 +00:00
parent 1ee00f1c7b
commit bbdc24dfab
4 changed files with 17 additions and 26 deletions

View file

@ -9,6 +9,11 @@ struct MemoryOptions { // sizes are in KB
~MemoryOptions(); // sets options
};
enum {
UPP_HEAP_ALIGNMENT = 16,
UPP_HEAP_MINBLOCK = 32,
};
#ifdef UPP_HEAP
void *MemoryAllocPermanent(size_t size);

View file

@ -344,6 +344,7 @@ public:
void Swap(Array& b) { Swap(vector, b.vector); }
Array& operator<<(const T& x) { Add(x); return *this; }
Array& operator<<(T&& x) { Add(pick(x)); return *this; }
Array& operator<<(T *newt) { Add(newt); return *this; }
void Serialize(Stream& s) { StreamContainer(s, *this); }

View file

@ -522,16 +522,17 @@ rray][@(0.0.255) `&]_[*@3 b])&]
[s4;%- &]
[s5;:Array`:`:operator`<`<`(const T`&`):%- [_^topic`:`/`/Core`/src`/Array`$en`-us`#Array`:`:class^ A
rray][@(0.0.255) `&]_[* operator<<]([@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[*@3 x])&]
[s2; Operator replacement of [* void Add(const T`&x)]. By returning
a reference to the Array it allows adding more elements in a
single expression, thus e.g. allowing to construct a temporary
Array as part of an expression like Foo((Array<int>() << 1 <<
2 << 4)).&]
[s5;:Upp`:`:Array`:`:operator`<`<`(T`&`&`):%- [_^Upp`:`:Array^ Array][@(0.0.255) `&]_[* ope
rator<<]([*@4 T][@(0.0.255) `&`&]_[*@3 x])&]
[s2; Operator replacement of [* Add]. By returning a reference to the
Array it allows adding more elements in a single expression,
thus e.g. allowing to construct a temporary Array as part of
an expression like Foo((Array<int>() << 1 << 2 << 4)).&]
[s6; Requires T to have deep copy constructor.&]
[s6; Invalidates iterators to the Array.&]
[s7; [*C@3 x]-|The value that is copied to newly created element.&]
[s7; [*C@3 x]-|The value that is transferred to newly created element.&]
[s7; [*/ Return value]-|Reference to the Array (`*this).&]
[s3;%- &]
[s3; &]
[s4;%- &]
[s5;:Array`:`:operator`<`<`(T`*`):%- [_^topic`:`/`/Core`/src`/Array`$en`-us`#Array`:`:class^ A
rray][@(0.0.255) `&]_[* operator<<]([*@4 T]_`*[*@3 newt])&]
@ -544,24 +545,6 @@ an expression like Foo((Array<Bar>() << new Bar << new DerivedFromBar)).&]
[s7; [*/ Return value]-|Reference to the Array (`*this).&]
[s3;%- &]
[s4;%- &]
[s5;:Array`:`:operator`|`(pick`_ T`&`):%- [_^topic`:`/`/Core`/src`/Array`$en`-us`#Array`:`:class^ A
rray][@(0.0.255) `&]_[* operator`|]([@(0.128.128) pick`_]_[*@4 T][@(0.0.255) `&]_[*@3 x])&]
[s2; Operator replacement of [* void AddPick(pick`_ T`&x)]. By returning
a reference to the Array it allows adding more elements in a
single expression, thus e.g. allowing to construct a temporary
Array as part of an expression.&]
[s6; Requires T to have pick constructor.&]
[s6; Invalidates iterators to the Array.&]
[s7; [*C@3 x]-|Source instance of T that is to be picked.&]
[s7; [*/ Return value]-|Reference to Array (`*this).&]
[s3;%- &]
[s4;%- &]
[s5;:Array`:`:IsPicked`(`)const:%- [@(0.0.255) bool]_[* IsPicked]()_[@(0.0.255) const]&]
[s2; Returns [* true] if the Array is in picked state.&]
[s7; [*/ Return value]-|[* true] if the Array is in picked state, [* false]
otherwise.&]
[s3;%- &]
[s4;%- &]
[s5;:Array`:`:Serialize`(Stream`&`):%- [@(0.0.255) void]_[* Serialize]([_^topic`:`/`/Core`/src`/Stream`$en`-us`#Stream`:`:class^ S
tream][@(0.0.255) `&]_[*@3 s])&]
[s2; Serializes the content of the Array to/from the Stream. Works

View file

@ -31,7 +31,9 @@ checks.&]
ize`_t][@(0.0.255) `&]_[*@3 size])&]
[s2;%% Allocates a memory block of at least [%-*@3 size] bytes. [%-*@3 size]
is set to the real number of bytes in the block that can be used
by an application.&]
by an application. Guaranteed alignment is specified in [* UPP`_HEAP`_ALIGNMENT]
constant (currently 16). The minimal real size of returned block
in release mode is [* UPP`_HEAP`_MINBLOCK] (currently 32).&]
[s3;%% &]
[s4; &]
[s5;:Upp`:`:MemoryAlloc`(size`_t`): [@(0.0.255) void]_`*[* MemoryAlloc]([_^size`_t^ size`_t