diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/editor.xml b/.idea/editor.xml
new file mode 100644
index 0000000..25c6c37
--- /dev/null
+++ b/.idea/editor.xml
@@ -0,0 +1,344 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/fennec.iml b/.idea/fennec.iml
new file mode 100644
index 0000000..f08604b
--- /dev/null
+++ b/.idea/fennec.iml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..0b76fe5
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..2767e77
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/doxy/.Doxyfile.in.swp b/doxy/.Doxyfile.in.swp
new file mode 100644
index 0000000..f5a3136
Binary files /dev/null and b/doxy/.Doxyfile.in.swp differ
diff --git a/include/fennec/containers/dynarray.h b/include/fennec/containers/dynarray.h
index 531f199..3a25a1c 100644
--- a/include/fennec/containers/dynarray.h
+++ b/include/fennec/containers/dynarray.h
@@ -30,7 +30,10 @@
#ifndef FENNEC_CONTAINERS_DYNARRAY_H
#define FENNEC_CONTAINERS_DYNARRAY_H
+
+#include
#include
+#include
namespace fennec
{
@@ -42,10 +45,45 @@ public:
using element_t = T;
using alloc_t = Alloc;
+ ///
+ /// \brief Default Constructor, initializes an empty allocation.
dynarray() : _alloc(), _size(0) {}
- dynarray(size_t size) : _alloc(size), _size(size) { }
+
+ ///
+ /// \breif Alloc Constructor, initalize empty allocation with allocator instance.
+ /// \param alloc An allocator object to copy, for instances where the allocator needs to be initialized with some data.
dynarray(const alloc_t& alloc) : _alloc(alloc), _size(0) {}
+ ///
+ /// \brief Create an allocation with a size of `n` elements. All elements are initialized with the default constructor.
+ dynarray(size_t n) : _alloc(n), _size(n)
+ {
+ element_t* addr = _alloc.data();
+ for(; n > 0; --n, ++addr) { fennec::construct(addr); }
+ }
+
+ ///
+ /// \brief Create an allocation of size `n`, with each element constructed using the copy constructor
+ /// \brief n the number of elements
+ dynarray(size_t n, const element_t& val)
+ {
+ element_t* addr = _alloc.data();
+ for(; n > 0; --n, ++addr) { fennec::construct(addr, val); }
+ }
+
+ template
+ dynarray(size_t n, ArgsT...args)
+ {
+ element_t* addr = _alloc.data();
+ for(; n > 0; --n, ++addr) { fennec::construct(addr, args...); }
+ }
+
+ ~dynarray()
+ {
+ element_t* addr = _alloc.data();
+ for(; n > 0; --n, ++addr) { fennec::destruct(addr); }
+ }
+
private:
allocation _alloc;
size_t _size;
diff --git a/include/fennec/lang/intrinsics.h b/include/fennec/lang/intrinsics.h
index 8cb5f9f..29861ec 100644
--- a/include/fennec/lang/intrinsics.h
+++ b/include/fennec/lang/intrinsics.h
@@ -93,8 +93,8 @@
// Difficult and Inconsistent without intrinsics
#if __has_builtin(__is_constructible)
-# define FENNEC_BUILTIN_CAN_CONSTRUCT 1
-# define FENNEC_BUILTIN_CAN_CONSTRUCT(type, args...) __is_constructible(type, args)
+# define FENNEC_HAS_BUILTIN_CAN_CONSTRUCT 1
+# define FENNEC_BUILTIN_CAN_CONSTRUCT(type, ...) __is_constructible(type, __VA_ARGS__)
#else
# define FENNEC_HAS_BUILTIN_CAN_CONSTRUCT 0
#endif
diff --git a/include/fennec/memory/allocator.h b/include/fennec/memory/allocator.h
index 8d47db3..b1b5d36 100644
--- a/include/fennec/memory/allocator.h
+++ b/include/fennec/memory/allocator.h
@@ -20,7 +20,6 @@
#ifndef FENNEC_MEMORY_ALLOCATOR_H
#define FENNEC_MEMORY_ALLOCATOR_H
-#include
#include
#include
#include
@@ -279,9 +278,14 @@ public:
///
/// \brief Getter for the number of elements `n` of type `T` that the allocation can hold.
- /// \return the size of the allocation in elements
+ /// \returns the size of the allocation in elements
constexpr size_t capacity() const { return _capacity; }
+ ///
+ /// \brief Getter for the real pointer to the allocated block of memory
+ /// \returns Pointer to the allocated memory.
+ constexpr value_t* data() { return _data; }
+
private:
alloc_t _alloc; // Allocator object
value_t* _data; // Handle for the memory block
diff --git a/include/fennec/memory/new.h b/include/fennec/memory/new.h
index 7bd7c78..c7ccdea 100644
--- a/include/fennec/memory/new.h
+++ b/include/fennec/memory/new.h
@@ -24,6 +24,7 @@
#include
#include
+#include
namespace fennec
{
@@ -36,6 +37,15 @@ enum class align_t : size_t;
/// \brief Type to handle explicit nothrow definitions
struct nothrow_t { explicit nothrow_t() noexcept { } };
+template void construct(TypeT* ptr)
+ { ptr->TypeT(); }
+
+template void construct(TypeT* ptr, ArgsT...args)
+ { ptr->TypeT(fennec::forward(args)...); }
+
+template void destruct(TypeT* ptr)
+ { ptr->~TypeT(); }
+
}
#endif // FENNEC_MEMORY_NEW_H