Move memory functions into memory.lifecycle
- move - moveEmplace - forward - emplace - swap
This commit is contained in:
@ -1,5 +1,12 @@
|
||||
{
|
||||
"name": "meta",
|
||||
"description": "Template metaprogramming",
|
||||
"targetType": "library"
|
||||
"targetType": "library",
|
||||
|
||||
"sourcePaths": [
|
||||
"."
|
||||
],
|
||||
"importPaths": [
|
||||
"."
|
||||
]
|
||||
}
|
||||
|
@ -9,11 +9,11 @@
|
||||
* It contains different algorithms for iterating, searching and modifying
|
||||
* template arguments.
|
||||
*
|
||||
* Copyright: Eugene Wissner 2017-2018.
|
||||
* Copyright: Eugene Wissner 2017-2019.
|
||||
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
||||
* Mozilla Public License, v. 2.0).
|
||||
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
||||
* Source: $(LINK2 https://github.com/caraus-ecms/tanya/blob/master/source/tanya/meta/metafunction.d,
|
||||
* Source: $(LINK2 https://github.com/caraus-ecms/tanya/blob/master/meta/tanya/meta/metafunction.d,
|
||||
* tanya/meta/metafunction.d)
|
||||
*/
|
||||
module tanya.meta.metafunction;
|
@ -9,11 +9,11 @@
|
||||
* to transform from one type to another. It has also different algorithms for
|
||||
* iterating, searching and modifying template arguments.
|
||||
*
|
||||
* Copyright: Eugene Wissner 2017-2018.
|
||||
* Copyright: Eugene Wissner 2017-2019.
|
||||
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
||||
* Mozilla Public License, v. 2.0).
|
||||
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
||||
* Source: $(LINK2 https://github.com/caraus-ecms/tanya/blob/master/source/tanya/meta/package.d,
|
||||
* Source: $(LINK2 https://github.com/caraus-ecms/tanya/blob/master/meta/tanya/meta/package.d,
|
||||
* tanya/meta/package.d)
|
||||
*/
|
||||
module tanya.meta;
|
@ -8,11 +8,11 @@
|
||||
* Templates in this module are used to obtain type information at compile
|
||||
* time.
|
||||
*
|
||||
* Copyright: Eugene Wissner 2017-2018.
|
||||
* Copyright: Eugene Wissner 2017-2019.
|
||||
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
||||
* Mozilla Public License, v. 2.0).
|
||||
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
||||
* Source: $(LINK2 https://github.com/caraus-ecms/tanya/blob/master/source/tanya/meta/trait.d,
|
||||
* Source: $(LINK2 https://github.com/caraus-ecms/tanya/blob/master/meta/tanya/meta/trait.d,
|
||||
* tanya/meta/trait.d)
|
||||
*/
|
||||
module tanya.meta.trait;
|
||||
@ -2692,6 +2692,58 @@ if (is(T == class))
|
||||
static assert(classInstanceAlignment!C2 == S.alignof);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size in bytes of the state that needs to be allocated to hold an
|
||||
* object of type $(D_PARAM T).
|
||||
*
|
||||
* There is a difference between the `.sizeof`-property and
|
||||
* $(D_PSYMBOL stateSize) if $(D_PARAM T) is a class or an interface.
|
||||
* `T.sizeof` is constant on the given architecture then and is the same as
|
||||
* `size_t.sizeof` and `ptrdiff_t.sizeof`. This is because classes and
|
||||
* interfaces are reference types and `.sizeof` returns the size of the
|
||||
* reference which is the same as the size of a pointer. $(D_PSYMBOL stateSize)
|
||||
* returns the size of the instance itself.
|
||||
*
|
||||
* The size of a dynamic array is `size_t.sizeof * 2` since a dynamic array
|
||||
* stores its length and a data pointer. The size of the static arrays is
|
||||
* calculated differently since they are value types. It is the array length
|
||||
* multiplied by the element size.
|
||||
*
|
||||
* `stateSize!void` is `1` since $(D_KEYWORD void) is mostly used as a synonym
|
||||
* for $(D_KEYWORD byte)/$(D_KEYWORD ubyte) in `void*`.
|
||||
*
|
||||
* Params:
|
||||
* T = Object type.
|
||||
*
|
||||
* Returns: Size of an instance of type $(D_PARAM T).
|
||||
*/
|
||||
template stateSize(T)
|
||||
{
|
||||
static if (isPolymorphicType!T)
|
||||
{
|
||||
enum size_t stateSize = __traits(classInstanceSize, T);
|
||||
}
|
||||
else
|
||||
{
|
||||
enum size_t stateSize = T.sizeof;
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
@nogc nothrow pure @safe unittest
|
||||
{
|
||||
static assert(stateSize!int == 4);
|
||||
static assert(stateSize!bool == 1);
|
||||
static assert(stateSize!(int[]) == (size_t.sizeof * 2));
|
||||
static assert(stateSize!(short[3]) == 6);
|
||||
|
||||
static struct Empty
|
||||
{
|
||||
}
|
||||
static assert(stateSize!Empty == 1);
|
||||
static assert(stateSize!void == 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether $(D_INLINECODE pred(T)) can be used as condition in an
|
||||
* $(D_KEYWORD if)-statement or a ternary operator.
|
@ -9,11 +9,11 @@
|
||||
* types. They take some type as argument and return a different type after
|
||||
* perfoming the specified transformation.
|
||||
*
|
||||
* Copyright: Eugene Wissner 2017-2018.
|
||||
* Copyright: Eugene Wissner 2017-2019.
|
||||
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
||||
* Mozilla Public License, v. 2.0).
|
||||
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
||||
* Source: $(LINK2 https://github.com/caraus-ecms/tanya/blob/master/source/tanya/meta/transform.d,
|
||||
* Source: $(LINK2 https://github.com/caraus-ecms/tanya/blob/master/meta/tanya/meta/transform.d,
|
||||
* tanya/meta/transform.d)
|
||||
*/
|
||||
module tanya.meta.transform;
|
Reference in New Issue
Block a user