- Adjusted Formatting of tests

- Finished map implementation and unit tests

 TODO: Threading
This commit is contained in:
2025-07-23 12:05:02 -04:00
parent 73333b4c67
commit 5ab2952e83
63 changed files with 2703 additions and 2187 deletions

View File

@@ -0,0 +1,59 @@
// =====================================================================================================================
// fennec, a free and open source game engine
// Copyright © 2025 Medusa Slockbower
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#ifndef FENNEC_CONTAINERS_DETAIL_TUPLE_H
#define FENNEC_CONTAINERS_DETAIL_TUPLE_H
#include <fennec/lang/sequences.h>
#include <fennec/lang/utility.h>
namespace fennec::detail
{
// leaves
template<size_t i, typename T>
struct __tuple_leaf {
T value;
template<typename...ArgsT>
__tuple_leaf(ArgsT&&...args) : value(args...) {
}
constexpr operator T&() {
return value;
}
constexpr operator const T&() const {
return value;
}
};
// proxy
template<typename, typename...TypesT>
struct __tuple;
template<size_t...i, typename...TypesT>
struct __tuple<index_sequence<i...>, TypesT...> : __tuple_leaf<i, TypesT>... {
template<typename...ArgsT>
__tuple(ArgsT&&...args) : __tuple_leaf<i, TypesT>(args)... {
}
};
}
#endif // FENNEC_CONTAINERS_DETAIL_TUPLE_H

View File

@@ -27,6 +27,24 @@ namespace fennec
// TODO: Document
/* Ramblings
*
* Definitions:
* user = Programmer using this data structure
*
* The STL unordered-map is very contrived. Some of its functionality encourages younger programmers to use
* the exception model. Ideally, I would like this structure to never throw an error with typical use.
*
* The array access operator is, in my opinion, poorly implemented. I do not think that this operator should handle
* insertions and should handle access only. This is the only data structure in STL that has this behavior, no other
* data structure modifies contents by inherently calling operator[].
*
* Currently, I am considering implementing this as the following:
* Access will be handled only via operator[]. Return value will be an optional which forces user validation.
* Insertions will be handled only via an insert/emplace function.
* Deletions will be handled only via an erase function.
*/
template<typename KeyT, typename ValueT, typename Hash = hash<KeyT>, typename Alloc = allocator<pair<KeyT, ValueT>>>
struct map {
public:
@@ -36,13 +54,136 @@ public:
using alloc_t = typename allocator_traits<Alloc>::template rebind<elem_t>;
using hash_t = Hash;
map() = default;
~map() = default;
// We only want to hash the key
struct key_hash : hash_t {
constexpr size_t operator()(const elem_t& p) const {
return hash_t::operator()(p.first);
}
};
// We only want to compare the keys
struct node_equals : equality<KeyT> {
constexpr bool operator()(const elem_t& a, const elem_t& b) const {
return equality<KeyT>::operator()(a.first, b.first);
}
};
constexpr map() = default;
constexpr ~map() = default;
constexpr value_t* operator[](const KeyT& key) {
union U { // Hacky way of avoiding constructing the value, TODO: Check for warnings on other compilers
pair<KeyT, char[sizeof(ValueT)]> root;
pair<KeyT, ValueT> val;
~U() {
root.~pair<KeyT, char[sizeof(ValueT)]>();
}
} trick = { .root = { key, 0 } };
auto it = _set.find(trick.val);
if (it == _set.end()) {
return nullptr;
}
return &_set.at(it)->second;
}
constexpr const value_t* operator[](const KeyT& key) const {
union U { // Hacky way of avoiding constructing the value, TODO: Check for warnings on other compilers
pair<KeyT, char[sizeof(ValueT)]> root;
pair<KeyT, ValueT> val;
~U() {
root.~pair<KeyT, char[sizeof(ValueT)]>();
}
} trick = { .root = { key, 0 } }; // Only initialize root
auto it = _set.find(trick.val);
if (it == _set.end()) {
return nullptr;
}
return &_set.at(it)->second;
}
template<typename...ArgsT>
constexpr value_t* operator[](ArgsT&&...args) {
union U { // Hacky way of avoiding constructing the value, TODO: Check for warnings on other compilers
pair<KeyT, char[sizeof(ValueT)]> root;
pair<KeyT, ValueT> val;
~U() {
root.~pair<KeyT, char[sizeof(ValueT)]>();
}
} trick = { .root = { key_t(fennec::forward<ArgsT>(args)...), 0 } }; // Only initialize root
auto it = _set.find(trick.val);
if (it == _set.end()) {
return nullptr;
}
return &_set.at(it)->second;
}
template<typename...ArgsT>
constexpr const value_t* operator[](ArgsT&&...args) const {
union U { // Hacky way of avoiding constructing the value, TODO: Check for warnings on other compilers
pair<KeyT, char[sizeof(ValueT)]> root;
pair<KeyT, ValueT> val;
~U() {
root.~pair<KeyT, char[sizeof(ValueT)]>();
}
} trick = { .root = { key_t(fennec::forward<ArgsT>(args)...), 0 } }; // Only initialize root
auto it = _set.find(trick.val);
if (it == _set.end()) {
return nullptr;
}
return &_set.at(it)->second;
}
constexpr void insert(elem_t&& pair) {
auto it = _set.find(pair);
if (it == _set.end()) {
_set.at(it)->second = fennec::move(pair.second);
return;
}
_set.insert(fennec::forward<elem_t>(pair));
}
template<typename...ArgsT>
constexpr void emplace(ArgsT&&...args) {
_set.insert(elem_t(args...));
}
constexpr void erase(KeyT&& key) {
union U { // Hacky way of avoiding constructing the value, TODO: Check for warnings on other compilers
pair<KeyT, char[sizeof(ValueT)]> root;
pair<KeyT, ValueT> val;
~U() {
root.~pair<KeyT, char[sizeof(ValueT)]>();
}
} trick = { .root = { fennec::forward<KeyT>(key), 0 } };
_set.erase(trick.val);
}
constexpr void erase(const KeyT& key) {
KeyT val = key;
erase(fennec::move(val));
}
template<typename...ArgsT>
constexpr void erase(ArgsT&&...args) {
union U { // Hacky way of avoiding constructing the value, TODO: Check for warnings on other compilers
pair<KeyT, char[sizeof(ValueT)]> root;
pair<KeyT, ValueT> val;
~U() {
root.~pair<KeyT, char[sizeof(ValueT)]>();
}
} trick = { .root = { KeyT(fennec::forward<ArgsT>(args)...), 0 } };
_set.erase(trick.val);
}
private:
set<elem_t, hash_t, alloc_t> _set;
set<elem_t, key_hash, node_equals, alloc_t> _set;
};
}

View File

@@ -39,6 +39,10 @@ template<typename T>
struct optional {
public:
// Constructors ========================================================================================================
using reference_t = T&;
using pointer_t = add_pointer_t<remove_reference_t<T>>;
using const_reference_t = const T&;
using const_pointer_t = const add_pointer_t<remove_reference_t<T>>;
///
/// \brief Default Constructor
@@ -203,11 +207,11 @@ public:
return _set;
}
constexpr T* operator->() noexcept {
constexpr pointer_t operator->() noexcept {
return _set ? &_val : nullptr;
}
constexpr const T* operator->() const noexcept {
constexpr const pointer_t operator->() const noexcept {
return _set ? &_val : nullptr;
}

View File

@@ -19,6 +19,7 @@
#ifndef FENNEC_CONTAINERS_PAIR_H
#define FENNEC_CONTAINERS_PAIR_H
#include <fennec/containers/tuple.h>
#include <fennec/lang/hashing.h>
#include <fennec/lang/utility.h>
@@ -42,6 +43,12 @@ struct pair {
, second(fennec::forward<T1>(y)) {
}
template<typename Arg1T, typename Arg2T>
constexpr pair(Arg1T&& arg1, Arg2T&& arg2)
: first(fennec::forward<Arg1T>(arg1))
, second(fennec::forward<Arg2T>(arg2)) {
}
constexpr pair(const pair&) = default;
constexpr pair(pair&&) noexcept = default;

View File

@@ -22,6 +22,7 @@
// https://programming.guide/robin-hood-hashing.html
#include <fennec/containers/optional.h>
#include <fennec/lang/compare.h>
#include <fennec/math/ext/primes.h>
#include <fennec/memory/allocator.h>
#include <fennec/lang/hashing.h>
@@ -31,15 +32,17 @@ namespace fennec
// TODO: Document
template<typename T, class Hash = hash<T>, class Alloc = allocator<T>>
template<typename T, class Hash = hash<T>, class Equals = equality<T>, class Alloc = allocator<T>>
struct set {
public:
using alloc_t = typename allocator_traits<Alloc>::template rebind<T>;
using hash_t = Hash;
using equal_t = Equals;
using elem_t = T;
class iterator;
static constexpr size_t npos = -1;
static constexpr double default_load = 0.8;
private:
struct node {
@@ -54,60 +57,71 @@ public:
constexpr set()
: _alloc()
, _hash()
, _size(0) {
, _size(0)
, _load(default_load) {
};
constexpr set(const hash_t& hash)
: _alloc()
, _hash(hash)
, _size(0) {
, _size(0)
, _load(default_load) {
}
constexpr set(hash_t&& hash) noexcept
: _alloc()
, _hash(hash)
, _size(0) {
, _size(0)
, _load(default_load) {
}
constexpr set(const alloc_t& alloc)
: _alloc(alloc)
, _hash()
, _size(0) {
, _size(0)
, _load(default_load) {
}
constexpr set(alloc_t&& alloc) noexcept
: _alloc(alloc)
, _hash()
, _size(0) {
, _size(0)
, _load(default_load) {
}
constexpr set(const hash_t& hash, const alloc_t& alloc)
: _alloc(alloc)
, _hash(hash)
, _size(0) {
, _size(0)
, _load(default_load) {
}
constexpr set(const hash_t& hash, alloc_t&& alloc) noexcept
: _alloc(alloc)
, _hash(hash)
, _size(0) {
, _size(0)
, _load(default_load) {
}
constexpr set(hash_t&& hash, alloc_t&& alloc) noexcept
: _alloc(alloc)
, _hash(hash)
, _size(0) {
, _size(0)
, _load(default_load) {
}
constexpr set(hash_t&& hash, const alloc_t& alloc) noexcept
: _alloc(alloc)
, _hash(hash)
, _size(0) {}
, _size(0)
, _load(default_load) {
}
constexpr set(const set& set)
: _alloc(set._alloc)
, _hash(set._hash)
, _size(set._size) {
, _size(set._size)
, _load(default_load) {
}
constexpr set(set&& set) noexcept
@@ -127,7 +141,7 @@ public:
}
constexpr void insert(elem_t&& val) {
if (_size >= capacity()) { // expand when full
if (_size == 0 or double(_size) / capacity() >= _load) { // expand when full
_expand();
}
@@ -135,7 +149,7 @@ public:
size_t i = _hash(value) % capacity(); // Initial search index
int psl = 0;
while (_alloc[i].value) { // Search for empty cell
if (*_alloc[i].value == val) { // Check to see if this element is already inserted
if (_equal(*_alloc[i].value, val)) { // Check to see if this element is already inserted
return;
}
if (psl >= _alloc[i].psl) { // When psl is higher, swap
@@ -165,8 +179,8 @@ public:
int psl = 0;
// Loop while there is a value and its psl is greater than our probe
while (_alloc[i].value && _alloc[i].psl > psl) {
if (*_alloc[i].value == val) {
while (_alloc[i].value && _alloc[i].psl <= psl) {
if (_equal(*_alloc[i].value, val)) {
return iterator(this, i);
}
i = (i + 1) % capacity(); ++psl;
@@ -175,6 +189,20 @@ public:
return iterator(this, npos);
}
constexpr elem_t* at(const iterator& it) {
size_t i = it._i;
if (i >= capacity()) return nullptr;
if (not _alloc[i].value) return nullptr;
return &*_alloc[i].value;
}
constexpr const elem_t* at(const iterator& it) const {
size_t i = it._i;
if (i >= capacity()) return nullopt;
if (not _alloc[i].value) return nullopt;
return &*_alloc[i].value;
}
constexpr bool contains(const elem_t& val) const {
return this->find(val) != end();
}
@@ -251,6 +279,7 @@ public:
private:
const set* _set;
size_t _i;
friend set;
};
constexpr iterator begin() const {
@@ -271,10 +300,9 @@ public:
private:
constexpr void _expand() {
set cpy; // Create a new set
cpy._alloc.allocate(
cpy._alloc.callocate(
fennec::next_prime2(_alloc.capacity())
);
fennec::memset(cpy._alloc.data(), 0, cpy._alloc.size());
// rehash
for (size_t i = 0; i < capacity(); ++i) {
@@ -289,7 +317,9 @@ private:
allocation<node, alloc_t> _alloc;
hash_t _hash;
equal_t _equal;
size_t _size;
double _load;
};
}

View File

@@ -0,0 +1,64 @@
// =====================================================================================================================
// fennec, a free and open source game engine
// Copyright © 2025 Medusa Slockbower
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#ifndef FENNEC_CONTAINERS_TUPLE_H
#define FENNEC_CONTAINERS_TUPLE_H
#include <fennec/containers/detail/__tuple.h>
#include <fennec/lang/type_sequences.h>
namespace fennec
{
// TODO: Document
template<typename...TypesT> struct tuple;
template<size_t i, typename...TypesT>
typename tuple<TypesT...>::template elem_t<i>& get(tuple<TypesT...>& x) {
using elem_t = typename tuple<TypesT...>::template elem_t<i>;
auto it = static_cast<detail::__tuple_leaf<i, elem_t>>(x);
return it;
}
template<size_t i, typename...TypesT>
const typename tuple<TypesT...>::template elem_t<i>& get(tuple<TypesT...>& x) {
using elem_t = typename tuple<TypesT...>::template elem_t<i>;
auto& it = static_cast<detail::__tuple_leaf<i, elem_t>>(x);
return it;
}
template<typename...TypesT>
struct tuple : detail::__tuple<make_index_sequence<sizeof...(TypesT)>, TypesT...> {
public:
using base_t = detail::__tuple<make_index_sequence<sizeof...(TypesT)>, TypesT...>;
template<size_t i>
using elem_t = nth_element<i, TypesT...>;
template<typename...ArgsT>
tuple(ArgsT&&...args) : base_t(args...) {
}
};
}
#endif // FENNEC_CONTAINERS_TUPLE_H

View File

@@ -25,6 +25,7 @@
#include <fennec/lang/assert.h>
#include <fennec/math/common.h>
#include <fennec/memory/bytes.h>
namespace fennec
{
@@ -303,6 +304,13 @@ private:
bool _const;
};
template<>
struct hash<cstring> : hash<byte_array> {
constexpr size_t operator()(const cstring& str) {
return hash<byte_array>::operator()(byte_array(*str, str.size()));
}
};
}
#endif // FENNEC_FPROC_STRINGS_CSTRING_H

View File

@@ -154,7 +154,7 @@ public:
/// \param i the index to access
/// \returns a copy of the character
constexpr char operator[](int i) const {
assertd(i >= 0 && i < size(), "Array Out of Bounds");
assertd(i >= 0 && (size_t)i < size(), "Array Out of Bounds");
return _str[i];
}
@@ -431,6 +431,13 @@ private:
alloc_t _str;
};
template<>
struct hash<string> : hash<byte_array> {
constexpr size_t operator()(const string& str) const {
return hash<byte_array>::operator()(byte_array(*str, str.size()));
}
};
}

View File

@@ -0,0 +1,123 @@
// =====================================================================================================================
// fennec, a free and open source game engine
// Copyright © 2025 Medusa Slockbower
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#ifndef FENNEC_LANG_COMPARE_H
#define FENNEC_LANG_COMPARE_H
#include <fennec/lang/type_operators.h>
namespace fennec
{
// equality ============================================================================================================
template<typename T0, typename T1 = T0> struct equality;
template<typename T0, typename T1> requires has_equals_v<T0, T1>
struct equality<T0, T1> {
constexpr bool operator()(const T0& x, const T1& y) const {
return x == y;
}
};
template<typename T0, typename T1> requires(not has_equals_v<T0, T1>
and has_less_v<T0, T1> and has_less_v<T1, T0>)
struct equality<T0, T1> {
constexpr bool operator()(const T0& x, const T1& y) const {
return not(x < y) and not(y < x);
}
};
template<typename T0, typename T1> requires(not(has_equals_v<T0, T1>)
and(not has_less_v<T0, T1> or not has_less_v<T1, T0>)
and(has_greater_v<T0, T1> and has_greater_v<T1, T0>))
struct equality<T0, T1> {
constexpr bool operator()(const T0& x, const T1& y) const {
return not(x > y) and not(y > x);
}
};
// inequality ==========================================================================================================
template<typename T0, typename T1 = T0> struct inequality;
template<typename T0, typename T1> requires has_nequals_v<T0, T1>
struct inequality<T0, T1> {
constexpr bool operator()(const T0& x, const T1& y) const {
return x != y;
}
};
template<typename T0, typename T1> requires has_less_v<T0, T1> and has_less_v<T1, T0>
struct inequality<T0, T1> {
constexpr bool operator()(const T0& x, const T1& y) const {
return (x < y) or (y < x);
}
};
template<typename T0, typename T1> requires has_greater_v<T0, T1> and has_greater_v<T1, T0>
struct inequality<T0, T1> {
constexpr bool operator()(const T0& x, const T1& y) const {
return (x > y) or (y > x);
}
};
// less ================================================================================================================
template<typename T0, typename T1 = T0> requires has_less_v<T0, T1>
struct less {
constexpr bool operator()(const T0& x, const T1& y) const {
return x < y;
}
};
// less_equal ==========================================================================================================
template<typename T0, typename T1 = T0> requires has_less_equals_v<T0, T1>
struct less_equals {
constexpr bool operator()(const T0& x, const T1& y) const {
return x <= y;
}
};
// less ================================================================================================================
template<typename T0, typename T1 = T0> requires has_greater_v<T0, T1>
struct greater {
constexpr bool operator()(const T0& x, const T1& y) const {
return x < y;
}
};
// less_equal ==========================================================================================================
template<typename T0, typename T1 = T0> requires has_greater_equals_v<T0, T1>
struct greater_equals {
constexpr bool operator()(const T0& x, const T1& y) const {
return x <= y;
}
};
}
#endif // FENNEC_LANG_COMPARE_H

View File

@@ -21,123 +21,118 @@
#include <fennec/lang/types.h>
namespace fennec
namespace fennec::detail
{
namespace detail
{
// helper for bitwise and for 1 byte
constexpr size_t __bit_and_8(void* dst, const void* src) {
*static_cast<uint8_t*>(dst) = *static_cast<uint8_t*>(dst) & *static_cast<const uint8_t*>(src); return 1;
}
// helper for bitwise and 2 bytes at once
constexpr size_t __bit_and_16(void* dst, const void* src) {
*static_cast<uint16_t*>(dst) = *static_cast<uint16_t*>(dst) & *static_cast<const uint16_t*>(src); return 2;
}
// helper for bitwise and 4 bytes at once
constexpr size_t __bit_and_32(void* dst, const void* src) {
*static_cast<uint32_t*>(dst) = *static_cast<uint32_t*>(dst) & *static_cast<const uint32_t*>(src); return 4;
}
// helper for bitwise and 8 bytes at once
constexpr size_t __bit_and_64(void* dst, const void* src) {
*static_cast<uint64_t*>(dst) = *static_cast<uint64_t*>(dst) & *static_cast<const uint64_t*>(src); return 8;
}
// helper for selecting size
constexpr size_t __bit_and(void* dst, const void* src, size_t n) {
switch (n) {
case 0:
return 0;
case 1:
return __bit_and_8(dst, src);
case 2: case 3:
return __bit_and_16(dst, src);
case 4: case 5: case 6: case 7:
return __bit_and_32(dst, src);
default:
return __bit_and_64(dst, src);
// helper for bitwise and for 1 byte
constexpr size_t __bit_and_8(void* dst, const void* src) {
*static_cast<uint8_t*>(dst) = *static_cast<uint8_t*>(dst) & *static_cast<const uint8_t*>(src); return 1;
}
}
// helper for bitwise or for 1 byte
constexpr size_t __bit_or_8(void* dst, const void* src) {
*static_cast<uint8_t*>(dst) = *static_cast<uint8_t*>(dst) | *static_cast<const uint8_t*>(src); return 1;
}
// helper for bitwise or 2 bytes at once
constexpr size_t __bit_or_16(void* dst, const void* src) {
*static_cast<uint16_t*>(dst) = *static_cast<uint16_t*>(dst) | *static_cast<const uint16_t*>(src); return 2;
}
// helper for bitwise or 4 bytes at once
constexpr size_t __bit_or_32(void* dst, const void* src) {
*static_cast<uint32_t*>(dst) = *static_cast<uint32_t*>(dst) | *static_cast<const uint32_t*>(src); return 4;
}
// helper for bitwise or 8 bytes at once
constexpr size_t __bit_or_64(void* dst, const void* src) {
*static_cast<uint64_t*>(dst) = *static_cast<uint64_t*>(dst) | *static_cast<const uint64_t*>(src); return 8;
}
// helper for selecting size
constexpr size_t __bit_or(void* dst, const void* src, size_t n) {
switch (n) {
case 0:
return 0;
case 1:
return __bit_or_8(dst, src);
case 2: case 3:
return __bit_or_16(dst, src);
case 4: case 5: case 6: case 7:
return __bit_or_32(dst, src);
default:
return __bit_or_64(dst, src);
// helper for bitwise and 2 bytes at once
constexpr size_t __bit_and_16(void* dst, const void* src) {
*static_cast<uint16_t*>(dst) = *static_cast<uint16_t*>(dst) & *static_cast<const uint16_t*>(src); return 2;
}
}
// helper for bitwise and 1 byte
constexpr size_t __bit_xor_8(void* dst, const void* src) {
*static_cast<uint8_t*>(dst) = *static_cast<uint8_t*>(dst) ^ *static_cast<const uint8_t*>(src); return 1;
}
// helper for bitwise xor 2 bytes at once
constexpr size_t __bit_xor_16(void* dst, const void* src) {
*static_cast<uint16_t*>(dst) = *static_cast<uint16_t*>(dst) ^ *static_cast<const uint16_t*>(src); return 2;
}
// helper for bitwise xor 4 bytes at once
constexpr size_t __bit_xor_32(void* dst, const void* src) {
*static_cast<uint32_t*>(dst) = *static_cast<uint32_t*>(dst) ^ *static_cast<const uint32_t*>(src); return 4;
}
// helper for bitwise xor 8 bytes at once
constexpr size_t __bit_xor_64(void* dst, const void* src) {
*static_cast<uint64_t*>(dst) = *static_cast<uint64_t*>(dst) ^ *static_cast<const uint64_t*>(src); return 8;
}
// helper for selecting size
constexpr size_t __bit_xor(void* dst, const void* src, size_t n) {
switch (n) {
case 0:
return 0;
case 1:
return __bit_xor_8(dst, src);
case 2: case 3:
return __bit_xor_16(dst, src);
case 4: case 5: case 6: case 7:
return __bit_xor_32(dst, src);
default:
return __bit_xor_64(dst, src);
// helper for bitwise and 4 bytes at once
constexpr size_t __bit_and_32(void* dst, const void* src) {
*static_cast<uint32_t*>(dst) = *static_cast<uint32_t*>(dst) & *static_cast<const uint32_t*>(src); return 4;
}
}
}
// helper for bitwise and 8 bytes at once
constexpr size_t __bit_and_64(void* dst, const void* src) {
*static_cast<uint64_t*>(dst) = *static_cast<uint64_t*>(dst) & *static_cast<const uint64_t*>(src); return 8;
}
// helper for selecting size
constexpr size_t __bit_and(void* dst, const void* src, size_t n) {
switch (n) {
case 0:
return 0;
case 1:
return __bit_and_8(dst, src);
case 2: case 3:
return __bit_and_16(dst, src);
case 4: case 5: case 6: case 7:
return __bit_and_32(dst, src);
default:
return __bit_and_64(dst, src);
}
}
// helper for bitwise or for 1 byte
constexpr size_t __bit_or_8(void* dst, const void* src) {
*static_cast<uint8_t*>(dst) = *static_cast<uint8_t*>(dst) | *static_cast<const uint8_t*>(src); return 1;
}
// helper for bitwise or 2 bytes at once
constexpr size_t __bit_or_16(void* dst, const void* src) {
*static_cast<uint16_t*>(dst) = *static_cast<uint16_t*>(dst) | *static_cast<const uint16_t*>(src); return 2;
}
// helper for bitwise or 4 bytes at once
constexpr size_t __bit_or_32(void* dst, const void* src) {
*static_cast<uint32_t*>(dst) = *static_cast<uint32_t*>(dst) | *static_cast<const uint32_t*>(src); return 4;
}
// helper for bitwise or 8 bytes at once
constexpr size_t __bit_or_64(void* dst, const void* src) {
*static_cast<uint64_t*>(dst) = *static_cast<uint64_t*>(dst) | *static_cast<const uint64_t*>(src); return 8;
}
// helper for selecting size
constexpr size_t __bit_or(void* dst, const void* src, size_t n) {
switch (n) {
case 0:
return 0;
case 1:
return __bit_or_8(dst, src);
case 2: case 3:
return __bit_or_16(dst, src);
case 4: case 5: case 6: case 7:
return __bit_or_32(dst, src);
default:
return __bit_or_64(dst, src);
}
}
// helper for bitwise and 1 byte
constexpr size_t __bit_xor_8(void* dst, const void* src) {
*static_cast<uint8_t*>(dst) = *static_cast<uint8_t*>(dst) ^ *static_cast<const uint8_t*>(src); return 1;
}
// helper for bitwise xor 2 bytes at once
constexpr size_t __bit_xor_16(void* dst, const void* src) {
*static_cast<uint16_t*>(dst) = *static_cast<uint16_t*>(dst) ^ *static_cast<const uint16_t*>(src); return 2;
}
// helper for bitwise xor 4 bytes at once
constexpr size_t __bit_xor_32(void* dst, const void* src) {
*static_cast<uint32_t*>(dst) = *static_cast<uint32_t*>(dst) ^ *static_cast<const uint32_t*>(src); return 4;
}
// helper for bitwise xor 8 bytes at once
constexpr size_t __bit_xor_64(void* dst, const void* src) {
*static_cast<uint64_t*>(dst) = *static_cast<uint64_t*>(dst) ^ *static_cast<const uint64_t*>(src); return 8;
}
// helper for selecting size
constexpr size_t __bit_xor(void* dst, const void* src, size_t n) {
switch (n) {
case 0:
return 0;
case 1:
return __bit_xor_8(dst, src);
case 2: case 3:
return __bit_xor_16(dst, src);
case 4: case 5: case 6: case 7:
return __bit_xor_32(dst, src);
default:
return __bit_xor_64(dst, src);
}
}
}

View File

@@ -22,42 +22,37 @@
#include <fennec/lang/types.h>
#include <fennec/lang/type_transforms.h>
namespace fennec
namespace fennec::detail
{
namespace detail
{
template<typename> struct __make_unsigned : type_identity<undefined_t> {};
template<typename> struct __make_unsigned : type_identity<undefined_t> {};
template<> struct __make_unsigned<char_t> : type_identity<uchar_t> {};
template<> struct __make_unsigned<uchar_t> : type_identity<uchar_t> {};
template<> struct __make_unsigned<schar_t> : type_identity<uchar_t> {};
template<> struct __make_unsigned<short_t> : type_identity<ushort_t> {};
template<> struct __make_unsigned<ushort_t> : type_identity<ushort_t> {};
template<> struct __make_unsigned<uint_t> : type_identity<uint_t> {};
template<> struct __make_unsigned<int_t> : type_identity<uint_t> {};
template<> struct __make_unsigned<long_t> : type_identity<ulong_t> {};
template<> struct __make_unsigned<ulong_t> : type_identity<ulong_t> {};
template<> struct __make_unsigned<llong_t> : type_identity<ullong_t> {};
template<> struct __make_unsigned<ullong_t> : type_identity<ullong_t> {};
template<> struct __make_unsigned<char_t> : type_identity<uchar_t> {};
template<> struct __make_unsigned<uchar_t> : type_identity<uchar_t> {};
template<> struct __make_unsigned<schar_t> : type_identity<uchar_t> {};
template<> struct __make_unsigned<short_t> : type_identity<ushort_t> {};
template<> struct __make_unsigned<ushort_t> : type_identity<ushort_t> {};
template<> struct __make_unsigned<uint_t> : type_identity<uint_t> {};
template<> struct __make_unsigned<int_t> : type_identity<uint_t> {};
template<> struct __make_unsigned<long_t> : type_identity<ulong_t> {};
template<> struct __make_unsigned<ulong_t> : type_identity<ulong_t> {};
template<> struct __make_unsigned<llong_t> : type_identity<ullong_t> {};
template<> struct __make_unsigned<ullong_t> : type_identity<ullong_t> {};
template<typename> struct __make_signed : type_identity<undefined_t> {};
template<typename> struct __make_signed : type_identity<undefined_t> {};
template<> struct __make_signed<char_t> : type_identity<schar_t> {};
template<> struct __make_signed<uchar_t> : type_identity<schar_t> {};
template<> struct __make_signed<schar_t> : type_identity<schar_t> {};
template<> struct __make_signed<short_t> : type_identity<short_t> {};
template<> struct __make_signed<ushort_t> : type_identity<short_t> {};
template<> struct __make_signed<uint_t> : type_identity<int_t> {};
template<> struct __make_signed<int_t> : type_identity<int_t> {};
template<> struct __make_signed<long_t> : type_identity<long_t> {};
template<> struct __make_signed<ulong_t> : type_identity<long_t> {};
template<> struct __make_signed<llong_t> : type_identity<llong_t> {};
template<> struct __make_signed<ullong_t> : type_identity<llong_t> {};
}
template<> struct __make_signed<char_t> : type_identity<schar_t> {};
template<> struct __make_signed<uchar_t> : type_identity<schar_t> {};
template<> struct __make_signed<schar_t> : type_identity<schar_t> {};
template<> struct __make_signed<short_t> : type_identity<short_t> {};
template<> struct __make_signed<ushort_t> : type_identity<short_t> {};
template<> struct __make_signed<uint_t> : type_identity<int_t> {};
template<> struct __make_signed<int_t> : type_identity<int_t> {};
template<> struct __make_signed<long_t> : type_identity<long_t> {};
template<> struct __make_signed<ulong_t> : type_identity<long_t> {};
template<> struct __make_signed<llong_t> : type_identity<llong_t> {};
template<> struct __make_signed<ullong_t> : type_identity<llong_t> {};
}

View File

@@ -21,16 +21,20 @@
#include <fennec/lang/type_transforms.h>
namespace fennec
namespace fennec::detail
{
namespace detail
{
template<typename FirstT, typename... RestT> struct __first_element : type_identity<FirstT> {};
template<typename FirstT, typename... RestT> struct __first_element : type_identity<FirstT>{};
template<size_t n, size_t i, typename...TypesT> struct __nth_element;
}
template<size_t n, size_t i> struct __nth_element<n, i> : type_identity<void> {};
template<size_t n, size_t i, typename HeadT, typename...RestT>
struct __nth_element<n, i, HeadT, RestT...> : conditional<
n == i, type_identity<HeadT>,
__nth_element<n, i + 1, RestT...>
> {};
}
#endif // FENNEC_LANG_DETAIL_TYPE_SEQUENCES_H

View File

@@ -22,53 +22,53 @@
#include <fennec/lang/constants.h>
#include <fennec/lang/float.h>
namespace fennec
namespace fennec::detail
{
namespace detail
{
// Nothing interesting to note here
template<typename> struct __is_void : false_type {};
template<> struct __is_void<void> : true_type {};
// Nothing interesting to note here
template<typename> struct __is_void : false_type {};
template<> struct __is_void<void> : true_type {};
template<typename> struct __is_bool : false_type {};
template<> struct __is_bool<bool_t> : true_type {};
template<typename> struct __is_bool : false_type {};
template<> struct __is_bool<bool_t> : true_type {};
template<typename> struct __is_null_pointer : false_type {};
template<> struct __is_null_pointer<nullptr_t> : true_type {};
template<typename> struct __is_null_pointer : false_type {};
template<> struct __is_null_pointer<nullptr_t> : true_type {};
// Provides definitions for all builtin int types
template<typename> struct __is_integral : false_type {};
template<> struct __is_integral<bool_t> : true_type {};
template<> struct __is_integral<char_t> : true_type {};
template<> struct __is_integral<char8_t> : true_type {};
template<> struct __is_integral<char16_t> : true_type {};
template<> struct __is_integral<char32_t> : true_type {};
template<> struct __is_integral<schar_t> : true_type {};
template<> struct __is_integral<uchar_t> : true_type {};
template<> struct __is_integral<wchar_t> : true_type {};
template<> struct __is_integral<short_t> : true_type {};
template<> struct __is_integral<ushort_t> : true_type {};
template<> struct __is_integral<int_t> : true_type {};
template<> struct __is_integral<uint_t> : true_type {};
template<> struct __is_integral<long_t> : true_type {};
template<> struct __is_integral<ulong_t> : true_type {};
template<> struct __is_integral<llong_t> : true_type {};
template<> struct __is_integral<ullong_t> : true_type {};
// Provides definitions for all builtin int types
template<typename> struct __is_integral : false_type {};
template<> struct __is_integral<bool_t> : true_type {};
template<> struct __is_integral<char_t> : true_type {};
template<> struct __is_integral<char8_t> : true_type {};
template<> struct __is_integral<char16_t> : true_type {};
template<> struct __is_integral<char32_t> : true_type {};
template<> struct __is_integral<schar_t> : true_type {};
template<> struct __is_integral<uchar_t> : true_type {};
template<> struct __is_integral<wchar_t> : true_type {};
template<> struct __is_integral<short_t> : true_type {};
template<> struct __is_integral<ushort_t> : true_type {};
template<> struct __is_integral<int_t> : true_type {};
template<> struct __is_integral<uint_t> : true_type {};
template<> struct __is_integral<long_t> : true_type {};
template<> struct __is_integral<ulong_t> : true_type {};
template<> struct __is_integral<llong_t> : true_type {};
template<> struct __is_integral<ullong_t> : true_type {};
// Most unsigned types will underflow `-1` to the types maximum value
template<typename TypeT> struct __is_signed : bool_constant<TypeT(-1) < TypeT(0)> {};
template<typename TypeT> struct __is_unsigned : bool_constant<TypeT(-1) >= TypeT(0)> {};
// Most unsigned types will underflow `-1` to the types maximum value
template<typename TypeT> struct __is_signed : bool_constant<TypeT(-1) < TypeT(0)> {};
template<typename TypeT> struct __is_unsigned : bool_constant<TypeT(-1) >= TypeT(0)> {};
template<typename> struct __is_floating_point : false_type {};
template<> struct __is_floating_point<float_t> : true_type {};
template<> struct __is_floating_point<double_t> : true_type {};
template<typename> struct __is_floating_point : false_type {};
template<> struct __is_floating_point<float_t> : true_type {};
template<> struct __is_floating_point<double_t> : true_type {};
template<typename> struct __is_pointer : false_type {};
template<typename T> struct __is_pointer<T*> : true_type {};
template<typename> struct __is_pointer : false_type {};
template<typename T> struct __is_pointer<T*> : true_type {};
template<typename T, typename U = T&&> U __declval(int);
template<typename T> T __declval(long);
}
template<typename T> struct __declval_protector : bool_constant<false> {};
}

View File

@@ -21,34 +21,29 @@
#include <fennec/lang/types.h>
namespace fennec
namespace fennec::detail
{
namespace detail
{
template<typename _Tp, typename = void>
struct __add_lvalue_reference {
using type = _Tp;
};
template<typename _Tp, typename = void>
struct __add_lvalue_reference {
using type = _Tp;
};
template<typename _Tp>
struct __add_lvalue_reference<_Tp, void_t<_Tp&>> {
using type = _Tp&;
};
template<typename _Tp>
struct __add_lvalue_reference<_Tp, void_t<_Tp&>> {
using type = _Tp&;
};
template<typename _Tp, typename = void>
struct __add_rvalue_reference {
using type = _Tp;
};
template<typename _Tp, typename = void>
struct __add_rvalue_reference {
using type = _Tp;
};
template<typename _Tp>
struct __add_rvalue_reference<_Tp, void_t<_Tp&&>> {
using type = _Tp&&;
};
}
template<typename _Tp>
struct __add_rvalue_reference<_Tp, void_t<_Tp&&>> {
using type = _Tp&&;
};
}

View File

@@ -0,0 +1,112 @@
// =====================================================================================================================
// fennec, a free and open source game engine
// Copyright © 2025 Medusa Slockbower
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#ifndef FENNEC_LANG_TYPE_OPERATORS_H
#define FENNEC_LANG_TYPE_OPERATORS_H
namespace fennec
{
// https://stackoverflow.com/questions/6534041/how-to-check-whether-operator-exists
// has_equals ==========================================================================================================
template<typename T0, typename T1 = T0>
struct has_equals {
// Use SFINAE to check for the operator
template<typename U, typename V> static auto test(U*) -> decltype(declval<U>() == declval<V>());
template<typename, typename> static auto test(...) -> false_type;
static constexpr bool value = is_same_v<bool, decltype(test<T0, T1>(0))>;
};
template<typename T0, typename T1 = T0> constexpr bool has_equals_v = has_equals<T0, T1>::value;
// has_nequals =========================================================================================================
template<typename T0, typename T1 = T0>
struct has_nequals {
// Use SFINAE to check for the operator
template<typename U, typename V> static auto test(U*) -> decltype(declval<U>() != declval<V>());
template<typename, typename> static auto test(...) -> false_type;
static constexpr bool value = is_same_v<bool, decltype(test<T0, T1>(0))>;
};
template<typename T0, typename T1 = T0> constexpr bool has_nequals_v = has_nequals<T0, T1>::value;
// has_less ============================================================================================================
template<typename T0, typename T1 = T0>
struct has_less {
// Use SFINAE to check for the operator
template<typename U, typename V> static auto test(U*) -> decltype(declval<U>() < declval<V>());
template<typename, typename> static auto test(...) -> false_type;
static constexpr bool value = is_same_v<bool, decltype(test<T0, T1>(0))>;
};
template<typename T0, typename T1 = T0> constexpr bool has_less_v = has_less<T0, T1>::value;
// has_less_equals =====================================================================================================
template<typename T0, typename T1 = T0>
struct has_less_equals {
// Use SFINAE to check for the operator
template<typename U, typename V> static auto test(U*) -> decltype(declval<U>() <= declval<V>());
template<typename, typename> static auto test(...) -> false_type;
static constexpr bool value = is_same_v<bool, decltype(test<T0, T1>(0))>;
};
template<typename T0, typename T1 = T0> constexpr bool has_less_equals_v = has_less_equals<T0, T1>::value;
// has_greater =========================================================================================================
template<typename T0, typename T1 = T0>
struct has_greater {
// Use SFINAE to check for the operator
template<typename U, typename V> static auto test(U*) -> decltype(declval<U>() > declval<V>());
template<typename, typename> static auto test(...) -> false_type;
static constexpr bool value = is_same_v<bool, decltype(test<T0, T1>(0))>;
};
template<typename T0, typename T1 = T0> constexpr bool has_greater_v = has_greater<T0, T1>::value;
// has_greater_equals ==================================================================================================
template<typename T0, typename T1 = T0>
struct has_greater_equals {
// Use SFINAE to check for the operator
template<typename U, typename V> static auto test(U*) -> decltype(declval<U>() >= declval<V>());
template<typename, typename> static auto test(...) -> false_type;
static constexpr bool value = is_same_v<bool, decltype(test<T0, T1>(0))>;
};
template<typename T0, typename T1 = T0> constexpr bool has_greater_equals_v = has_greater_equals<T0, T1>::value;
}
#endif // FENNEC_LANG_TYPE_OPERATORS_H

View File

@@ -69,6 +69,8 @@ template<typename...TypesT> struct first_element : detail::__first_element<Types
template<typename...TypesT> using first_element_t = typename first_element<TypesT...>::type;
template<size_t n, typename...TypesT> struct nth_element : detail::__nth_element<n, 0, TypesT...> {};
///
/// \brief Take a Template with a Pack `ClassT<ArgsT...>` and replace the first `ArgT` of `ArgsT...` with `SubT`

View File

@@ -112,6 +112,14 @@
namespace fennec
{
// fennec::declval =====================================================================================================
template<typename T> auto declval() noexcept -> decltype(detail::__declval<T>(0)) {
static_assert(detail::__declval_protector<T>{}, "declval must not be used");
return detail::__declval<T>(0);
}
// fennec::is_void =====================================================================================================
///

View File

@@ -20,32 +20,29 @@
#ifndef FENNEC_MATH_SWIZZLE_STORAGE_H
#define FENNEC_MATH_SWIZZLE_STORAGE_H
namespace fennec
namespace fennec::detail
{
namespace detail
{
///
/// \brief Backing storage struct for \ref fennec::swizzle "swizzle"
/// \tparam DataT Data Type
/// \tparam ScalarT Element Types
/// \tparam IndicesV Swizzle Order
//
// \brief Backing storage struct for \ref fennec::swizzle "swizzle"
// \tparam DataT Data Type
// \tparam ScalarT Element Types
// \tparam IndicesV Swizzle Order
template<typename DataT, typename ScalarT, size_t...IndicesV>
struct swizzle_storage
{
///
/// \brief an array containing the indices of this swizzle
//
// \brief an array containing the indices of this swizzle
inline static constexpr size_t indices[] = { IndicesV... };
///
/// \brief an array containing the scalar values of this swizzle
//
// \brief an array containing the scalar values of this swizzle
DataT data;
///
/// \brief element access, returns a copy of the value at index \p i
/// \param i the index
/// \returns a copy of the scalar value at index \p i
//
// \brief element access, returns a copy of the value at index \p i
// \param i the index
// \returns a copy of the scalar value at index \p i
constexpr ScalarT operator[](size_t i) const noexcept {
return data[indices[i]];
}
@@ -53,7 +50,5 @@ struct swizzle_storage
}
}
#endif // FENNEC_MATH_SWIZZLE_STORAGE_H

View File

@@ -27,65 +27,60 @@
#include <fennec/containers/array.h>
namespace fennec
namespace fennec::detail
{
namespace detail
{
///
/// \brief helper class for generating vectors
/// \tparam scalar base scalar type
/// \tparam size size of the vector type
//
// \brief helper class for generating vectors
// \tparam scalar base scalar type
// \tparam size size of the vector type
template<typename scalar, size_t size>
struct vector_base_type_helper
{
///
/// \var SizeV
/// \brief size of the vector type
//
// \var SizeV
// \brief size of the vector type
inline static constexpr size_t SizeV = size;
///
/// \brief Base scalar type
//
// \brief Base scalar type
using ScalarT = scalar;
///
/// \brief Base vector type
//
// \brief Base vector type
using VectorT = vec<ScalarT, SizeV>;
///
/// \brief Backing array holding the elements
//
// \brief Backing array holding the elements
using DataT = array<ScalarT, SizeV>;
///
/// \brief Helper for generating a swizzle from a set of indices
/// \tparam IndicesV Indices of the vector to pull from
//
// \brief Helper for generating a swizzle from a set of indices
// \tparam IndicesV Indices of the vector to pull from
template<size_t...IndicesV> struct SwizzleGen
{
/// \brief generated swizzle type
// \brief generated swizzle type
using type = swizzle<VectorT, DataT, ScalarT, IndicesV...>;
};
// Specialization for single component swizzles to decay into a scalar
template<size_t IndexV> struct SwizzleGen<IndexV>
{
/// \brief decayed scalar type
// \brief decayed scalar type
using type = ScalarT;
};
///
/// \brief backing storage type
//
// \brief backing storage type
using StorageT = vector_storage<SizeV, SwizzleGen, DataT>;
};
///
/// \brief helper for getting the storage type of the vector constructed with the provided size and scalar type
//
// \brief helper for getting the storage type of the vector constructed with the provided size and scalar type
template<typename ScalarT, size_t SizeV>
using vector_base_type = typename vector_base_type_helper<ScalarT, SizeV>::StorageT;
}
}
#endif // FENNEC_MATH_VECTOR_BASE_H

File diff suppressed because it is too large Load Diff

View File

@@ -467,7 +467,7 @@ public:
}
// Allocation and Deallocation =========================================================================================
// Allocation and Deallocation =====================================================================================
///
/// \brief Allocate a block of memory for the allocation.
@@ -483,6 +483,21 @@ public:
}
}
///
/// \brief Allocate a block of memory for the allocation.
/// If there is already an allocated block of memory, the previous allocation is released.
/// \param n The number of elements of type `T` to allocate for
constexpr void callocate(size_t n, align_t align = zero<align_t>()) noexcept {
deallocate();
if (align != zero<align_t>()) {
_data = _alloc.allocate(_capacity = n, _alignment = align);
} else {
_data = _alloc.allocate(_capacity = n);
}
fennec::memset(static_cast<void*>(_data), 0, _capacity * sizeof(T));
}
///
/// \brief Release the block of memory.
constexpr void deallocate() noexcept {

View File

@@ -92,7 +92,7 @@ public:
/// \returns a reference to the byte at `i`
constexpr byte_t& operator[](int i) {
assertd(not _const, "Attempted to Access Const-Qualified Memory as Non-Const");
assertd(i < _size, "Array Out of Bounds");
assertd(i >= 0 && (size_t)i < _size, "Array Out of Bounds");
return _arr[i];
}
@@ -102,7 +102,7 @@ public:
/// \returns a copy of the byte at `i`
constexpr byte_t operator[](int i) const {
assertd(not _const, "Attempted to Access Const-Qualified Memory as Non-Const");
assertd(i < _size, "Array Out of Bounds");
assertd(i >= 0 && (size_t)i < _size, "Array Out of Bounds");
return _carr[i];
}
@@ -123,7 +123,7 @@ public:
template<typename T>
constexpr const T* cast() const {
const void* temp = _carr;
return static_cast<T*>(temp);
return static_cast<const T*>(temp);
}
private:
@@ -139,7 +139,7 @@ private:
/// \brief Byte Array Hash Function
template<>
struct hash<byte_array> {
size_t operator()(const byte_array& bytes) {
size_t operator()(const byte_array& bytes) const {
// Murmur2
static constexpr uint64_t m = 0xc6a4a7935bd1e995;
@@ -148,7 +148,7 @@ struct hash<byte_array> {
const uint64_t n = bytes.size();
uint64_t h = s ^ (n * m);
const uint64_t* x = bytes.cast<>();
const uint64_t* x = bytes.cast<uint64_t>();
const uint64_t* y = x + (n / sizeof(uint64_t));
while (x != y) {
@@ -164,15 +164,16 @@ struct hash<byte_array> {
const uint8_t* b = (const uint8_t*)x;
switch (n & 7) {
case 7: h ^= uint64_t(b[6]) << 48;
case 6: h ^= uint64_t(b[5]) << 40;
case 5: h ^= uint64_t(b[4]) << 32;
case 4: h ^= uint64_t(b[3]) << 24;
case 3: h ^= uint64_t(b[2]) << 16;
case 2: h ^= uint64_t(b[1]) << 8;
case 7: h ^= uint64_t(b[6]) << 48; __attribute__((fallthrough));
case 6: h ^= uint64_t(b[5]) << 40; __attribute__((fallthrough));
case 5: h ^= uint64_t(b[4]) << 32; __attribute__((fallthrough));
case 4: h ^= uint64_t(b[3]) << 24; __attribute__((fallthrough));
case 3: h ^= uint64_t(b[2]) << 16; __attribute__((fallthrough));
case 2: h ^= uint64_t(b[1]) << 8; __attribute__((fallthrough));
case 1: h ^= uint64_t(b[0]);
h *= m;
default:
break;
}
h ^= h >> r;

View File

@@ -18,7 +18,7 @@
///
/// \file memory.h
/// \brief \ref
/// \brief \ref fennec_memory
///
///
/// \details
@@ -32,17 +32,9 @@
#define FENNEC_MEMORY_MEMORY_H
///
/// \page fennec_lang C++ Language Library
/// \page fennec_memory Memory Management Library
///
/// This library implements the parts of the C++ stdlib that relate to built-in types and metaprogramming.
///
/// - \subpage fennec_lang_assert
/// - \subpage fennec_lang_bit_manipulation
/// - \subpage fennec_lang_intrinsics
/// - \subpage fennec_lang_limits
/// - \subpage fennec_lang_metaprogramming
/// - \subpage fennec_lang_types
/// - \subpage fennec_lang_utility
/// This library implements functions and data structures to memory management and manipulation
///
///