- Adjusted Formatting of tests
- Finished map implementation and unit tests TODO: Threading
This commit is contained in:
@@ -31,6 +31,7 @@ set(FENNEC_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|||||||
# include scripts
|
# include scripts
|
||||||
include("${FENNEC_SOURCE_DIR}/cmake/platform.cmake")
|
include("${FENNEC_SOURCE_DIR}/cmake/platform.cmake")
|
||||||
include("${FENNEC_SOURCE_DIR}/cmake/build.cmake")
|
include("${FENNEC_SOURCE_DIR}/cmake/build.cmake")
|
||||||
|
include("${FENNEC_SOURCE_DIR}/cmake/compiler.cmake")
|
||||||
|
|
||||||
# find dependencies
|
# find dependencies
|
||||||
find_package(Doxygen)
|
find_package(Doxygen)
|
||||||
@@ -170,6 +171,9 @@ add_library(fennec STATIC
|
|||||||
|
|
||||||
|
|
||||||
${FENNEC_EXTRA_SOURCES}
|
${FENNEC_EXTRA_SOURCES}
|
||||||
|
include/fennec/lang/type_operators.h
|
||||||
|
include/fennec/containers/tuple.h
|
||||||
|
include/fennec/containers/detail/__tuple.h
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(fennec metaprogramming)
|
add_dependencies(fennec metaprogramming)
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
# ======================================================================================================================
|
# ======================================================================================================================
|
||||||
|
|
||||||
list(APPEND FENNEC_COMPILE_DEFINITIONS FENNEC_COMPILER_GCC=0)
|
|
||||||
|
|
||||||
if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
|
if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
|
||||||
set(FENNEC_COMPILER "GCC")
|
set(FENNEC_COMPILER "GCC")
|
||||||
include("${FENNEC_SOURCE_DIR}/cmake/gcc.cmake")
|
include("${FENNEC_SOURCE_DIR}/cmake/gcc.cmake")
|
||||||
|
|||||||
@@ -20,4 +20,4 @@ add_compile_options("-mxsave" "-Wall" "-Wextra" "-pedantic" "-Werror")
|
|||||||
|
|
||||||
set(FENNEC_PRIVATE_LINK_OPTIONS "-nostdlib" "-fno-exceptions" "-fno-rtti" "-fdiagnostics-all-candidates")
|
set(FENNEC_PRIVATE_LINK_OPTIONS "-nostdlib" "-fno-exceptions" "-fno-rtti" "-fdiagnostics-all-candidates")
|
||||||
|
|
||||||
list(APPEND FENNEC_COMPILE_DEFINITIONS FENNEC_COMPILER=FENNEC_COMPILER_GCC)
|
list(APPEND FENNEC_COMPILE_DEFINITIONS FENNEC_COMPILER_GCC=1)
|
||||||
@@ -18,6 +18,9 @@
|
|||||||
|
|
||||||
|
|
||||||
macro(fennec_check_platform)
|
macro(fennec_check_platform)
|
||||||
|
# unix
|
||||||
|
include("${FENNEC_SOURCE_DIR}/cmake/unix.cmake")
|
||||||
|
|
||||||
# compile definitions
|
# compile definitions
|
||||||
list(APPEND FENNEC_COMPILE_DEFINITIONS
|
list(APPEND FENNEC_COMPILE_DEFINITIONS
|
||||||
FENNEC_PLATFORM_NAME="Linux"
|
FENNEC_PLATFORM_NAME="Linux"
|
||||||
@@ -30,8 +33,8 @@ macro(fennec_check_platform)
|
|||||||
)
|
)
|
||||||
|
|
||||||
# includes
|
# includes
|
||||||
include("${FENNEC_SOURCE_DIR}/cmake/libwayland.cmake")
|
include("${FENNEC_SOURCE_DIR}/cmake/wayland.cmake")
|
||||||
|
|
||||||
# tests
|
# tests
|
||||||
fennec_check_libwayland()
|
fennec_check_wayland()
|
||||||
endmacro()
|
endmacro()
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
# https://gist.github.com/mariobadr/acc3c8adf4b4e722705be38c3deac59a
|
# https://gist.github.com/mariobadr/acc3c8adf4b4e722705be38c3deac59a
|
||||||
|
|
||||||
macro(fennec_check_libwayland)
|
macro(fennec_check_wayland)
|
||||||
set(WAYLAND_CLIENT_FOUND 0)
|
set(WAYLAND_CLIENT_FOUND 0)
|
||||||
|
|
||||||
find_path(
|
find_path(
|
||||||
@@ -48,7 +48,7 @@ PROJECT_NAME = fennec
|
|||||||
# could be handy for archiving the generated documentation or if some version
|
# could be handy for archiving the generated documentation or if some version
|
||||||
# control system is used.
|
# control system is used.
|
||||||
|
|
||||||
PROJECT_NUMBER =
|
PROJECT_NUMBER = 1.0.2
|
||||||
|
|
||||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||||
# for a project that appears at the top of each page and should give viewer a
|
# for a project that appears at the top of each page and should give viewer a
|
||||||
|
|||||||
59
include/fennec/containers/detail/__tuple.h
Normal file
59
include/fennec/containers/detail/__tuple.h
Normal 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
|
||||||
@@ -27,6 +27,24 @@ namespace fennec
|
|||||||
|
|
||||||
// TODO: Document
|
// 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>>>
|
template<typename KeyT, typename ValueT, typename Hash = hash<KeyT>, typename Alloc = allocator<pair<KeyT, ValueT>>>
|
||||||
struct map {
|
struct map {
|
||||||
public:
|
public:
|
||||||
@@ -36,13 +54,136 @@ public:
|
|||||||
using alloc_t = typename allocator_traits<Alloc>::template rebind<elem_t>;
|
using alloc_t = typename allocator_traits<Alloc>::template rebind<elem_t>;
|
||||||
using hash_t = Hash;
|
using hash_t = Hash;
|
||||||
|
|
||||||
map() = default;
|
// We only want to hash the key
|
||||||
~map() = default;
|
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:
|
private:
|
||||||
set<elem_t, hash_t, alloc_t> _set;
|
set<elem_t, key_hash, node_equals, alloc_t> _set;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ template<typename T>
|
|||||||
struct optional {
|
struct optional {
|
||||||
public:
|
public:
|
||||||
// Constructors ========================================================================================================
|
// 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
|
/// \brief Default Constructor
|
||||||
@@ -203,11 +207,11 @@ public:
|
|||||||
return _set;
|
return _set;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr T* operator->() noexcept {
|
constexpr pointer_t operator->() noexcept {
|
||||||
return _set ? &_val : nullptr;
|
return _set ? &_val : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr const T* operator->() const noexcept {
|
constexpr const pointer_t operator->() const noexcept {
|
||||||
return _set ? &_val : nullptr;
|
return _set ? &_val : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#ifndef FENNEC_CONTAINERS_PAIR_H
|
#ifndef FENNEC_CONTAINERS_PAIR_H
|
||||||
#define FENNEC_CONTAINERS_PAIR_H
|
#define FENNEC_CONTAINERS_PAIR_H
|
||||||
|
|
||||||
|
#include <fennec/containers/tuple.h>
|
||||||
#include <fennec/lang/hashing.h>
|
#include <fennec/lang/hashing.h>
|
||||||
#include <fennec/lang/utility.h>
|
#include <fennec/lang/utility.h>
|
||||||
|
|
||||||
@@ -42,6 +43,12 @@ struct pair {
|
|||||||
, second(fennec::forward<T1>(y)) {
|
, 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(const pair&) = default;
|
||||||
constexpr pair(pair&&) noexcept = default;
|
constexpr pair(pair&&) noexcept = default;
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
// https://programming.guide/robin-hood-hashing.html
|
// https://programming.guide/robin-hood-hashing.html
|
||||||
|
|
||||||
#include <fennec/containers/optional.h>
|
#include <fennec/containers/optional.h>
|
||||||
|
#include <fennec/lang/compare.h>
|
||||||
#include <fennec/math/ext/primes.h>
|
#include <fennec/math/ext/primes.h>
|
||||||
#include <fennec/memory/allocator.h>
|
#include <fennec/memory/allocator.h>
|
||||||
#include <fennec/lang/hashing.h>
|
#include <fennec/lang/hashing.h>
|
||||||
@@ -31,15 +32,17 @@ namespace fennec
|
|||||||
|
|
||||||
// TODO: Document
|
// 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 {
|
struct set {
|
||||||
public:
|
public:
|
||||||
using alloc_t = typename allocator_traits<Alloc>::template rebind<T>;
|
using alloc_t = typename allocator_traits<Alloc>::template rebind<T>;
|
||||||
using hash_t = Hash;
|
using hash_t = Hash;
|
||||||
|
using equal_t = Equals;
|
||||||
using elem_t = T;
|
using elem_t = T;
|
||||||
|
|
||||||
class iterator;
|
class iterator;
|
||||||
static constexpr size_t npos = -1;
|
static constexpr size_t npos = -1;
|
||||||
|
static constexpr double default_load = 0.8;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct node {
|
struct node {
|
||||||
@@ -54,60 +57,71 @@ public:
|
|||||||
constexpr set()
|
constexpr set()
|
||||||
: _alloc()
|
: _alloc()
|
||||||
, _hash()
|
, _hash()
|
||||||
, _size(0) {
|
, _size(0)
|
||||||
|
, _load(default_load) {
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr set(const hash_t& hash)
|
constexpr set(const hash_t& hash)
|
||||||
: _alloc()
|
: _alloc()
|
||||||
, _hash(hash)
|
, _hash(hash)
|
||||||
, _size(0) {
|
, _size(0)
|
||||||
|
, _load(default_load) {
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr set(hash_t&& hash) noexcept
|
constexpr set(hash_t&& hash) noexcept
|
||||||
: _alloc()
|
: _alloc()
|
||||||
, _hash(hash)
|
, _hash(hash)
|
||||||
, _size(0) {
|
, _size(0)
|
||||||
|
, _load(default_load) {
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr set(const alloc_t& alloc)
|
constexpr set(const alloc_t& alloc)
|
||||||
: _alloc(alloc)
|
: _alloc(alloc)
|
||||||
, _hash()
|
, _hash()
|
||||||
, _size(0) {
|
, _size(0)
|
||||||
|
, _load(default_load) {
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr set(alloc_t&& alloc) noexcept
|
constexpr set(alloc_t&& alloc) noexcept
|
||||||
: _alloc(alloc)
|
: _alloc(alloc)
|
||||||
, _hash()
|
, _hash()
|
||||||
, _size(0) {
|
, _size(0)
|
||||||
|
, _load(default_load) {
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr set(const hash_t& hash, const alloc_t& alloc)
|
constexpr set(const hash_t& hash, const alloc_t& alloc)
|
||||||
: _alloc(alloc)
|
: _alloc(alloc)
|
||||||
, _hash(hash)
|
, _hash(hash)
|
||||||
, _size(0) {
|
, _size(0)
|
||||||
|
, _load(default_load) {
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr set(const hash_t& hash, alloc_t&& alloc) noexcept
|
constexpr set(const hash_t& hash, alloc_t&& alloc) noexcept
|
||||||
: _alloc(alloc)
|
: _alloc(alloc)
|
||||||
, _hash(hash)
|
, _hash(hash)
|
||||||
, _size(0) {
|
, _size(0)
|
||||||
|
, _load(default_load) {
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr set(hash_t&& hash, alloc_t&& alloc) noexcept
|
constexpr set(hash_t&& hash, alloc_t&& alloc) noexcept
|
||||||
: _alloc(alloc)
|
: _alloc(alloc)
|
||||||
, _hash(hash)
|
, _hash(hash)
|
||||||
, _size(0) {
|
, _size(0)
|
||||||
|
, _load(default_load) {
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr set(hash_t&& hash, const alloc_t& alloc) noexcept
|
constexpr set(hash_t&& hash, const alloc_t& alloc) noexcept
|
||||||
: _alloc(alloc)
|
: _alloc(alloc)
|
||||||
, _hash(hash)
|
, _hash(hash)
|
||||||
, _size(0) {}
|
, _size(0)
|
||||||
|
, _load(default_load) {
|
||||||
|
}
|
||||||
|
|
||||||
constexpr set(const set& set)
|
constexpr set(const set& set)
|
||||||
: _alloc(set._alloc)
|
: _alloc(set._alloc)
|
||||||
, _hash(set._hash)
|
, _hash(set._hash)
|
||||||
, _size(set._size) {
|
, _size(set._size)
|
||||||
|
, _load(default_load) {
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr set(set&& set) noexcept
|
constexpr set(set&& set) noexcept
|
||||||
@@ -127,7 +141,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
constexpr void insert(elem_t&& val) {
|
constexpr void insert(elem_t&& val) {
|
||||||
if (_size >= capacity()) { // expand when full
|
if (_size == 0 or double(_size) / capacity() >= _load) { // expand when full
|
||||||
_expand();
|
_expand();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,7 +149,7 @@ public:
|
|||||||
size_t i = _hash(value) % capacity(); // Initial search index
|
size_t i = _hash(value) % capacity(); // Initial search index
|
||||||
int psl = 0;
|
int psl = 0;
|
||||||
while (_alloc[i].value) { // Search for empty cell
|
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;
|
return;
|
||||||
}
|
}
|
||||||
if (psl >= _alloc[i].psl) { // When psl is higher, swap
|
if (psl >= _alloc[i].psl) { // When psl is higher, swap
|
||||||
@@ -165,8 +179,8 @@ public:
|
|||||||
int psl = 0;
|
int psl = 0;
|
||||||
|
|
||||||
// Loop while there is a value and its psl is greater than our probe
|
// Loop while there is a value and its psl is greater than our probe
|
||||||
while (_alloc[i].value && _alloc[i].psl > psl) {
|
while (_alloc[i].value && _alloc[i].psl <= psl) {
|
||||||
if (*_alloc[i].value == val) {
|
if (_equal(*_alloc[i].value, val)) {
|
||||||
return iterator(this, i);
|
return iterator(this, i);
|
||||||
}
|
}
|
||||||
i = (i + 1) % capacity(); ++psl;
|
i = (i + 1) % capacity(); ++psl;
|
||||||
@@ -175,6 +189,20 @@ public:
|
|||||||
return iterator(this, npos);
|
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 {
|
constexpr bool contains(const elem_t& val) const {
|
||||||
return this->find(val) != end();
|
return this->find(val) != end();
|
||||||
}
|
}
|
||||||
@@ -251,6 +279,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
const set* _set;
|
const set* _set;
|
||||||
size_t _i;
|
size_t _i;
|
||||||
|
friend set;
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr iterator begin() const {
|
constexpr iterator begin() const {
|
||||||
@@ -271,10 +300,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
constexpr void _expand() {
|
constexpr void _expand() {
|
||||||
set cpy; // Create a new set
|
set cpy; // Create a new set
|
||||||
cpy._alloc.allocate(
|
cpy._alloc.callocate(
|
||||||
fennec::next_prime2(_alloc.capacity())
|
fennec::next_prime2(_alloc.capacity())
|
||||||
);
|
);
|
||||||
fennec::memset(cpy._alloc.data(), 0, cpy._alloc.size());
|
|
||||||
|
|
||||||
// rehash
|
// rehash
|
||||||
for (size_t i = 0; i < capacity(); ++i) {
|
for (size_t i = 0; i < capacity(); ++i) {
|
||||||
@@ -289,7 +317,9 @@ private:
|
|||||||
|
|
||||||
allocation<node, alloc_t> _alloc;
|
allocation<node, alloc_t> _alloc;
|
||||||
hash_t _hash;
|
hash_t _hash;
|
||||||
|
equal_t _equal;
|
||||||
size_t _size;
|
size_t _size;
|
||||||
|
double _load;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
64
include/fennec/containers/tuple.h
Normal file
64
include/fennec/containers/tuple.h
Normal 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
|
||||||
@@ -25,6 +25,7 @@
|
|||||||
#include <fennec/lang/assert.h>
|
#include <fennec/lang/assert.h>
|
||||||
|
|
||||||
#include <fennec/math/common.h>
|
#include <fennec/math/common.h>
|
||||||
|
#include <fennec/memory/bytes.h>
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec
|
||||||
{
|
{
|
||||||
@@ -303,6 +304,13 @@ private:
|
|||||||
bool _const;
|
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
|
#endif // FENNEC_FPROC_STRINGS_CSTRING_H
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ public:
|
|||||||
/// \param i the index to access
|
/// \param i the index to access
|
||||||
/// \returns a copy of the character
|
/// \returns a copy of the character
|
||||||
constexpr char operator[](int i) const {
|
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];
|
return _str[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -431,6 +431,13 @@ private:
|
|||||||
alloc_t _str;
|
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()));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
123
include/fennec/lang/compare.h
Normal file
123
include/fennec/lang/compare.h
Normal 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
|
||||||
@@ -21,10 +21,7 @@
|
|||||||
|
|
||||||
#include <fennec/lang/types.h>
|
#include <fennec/lang/types.h>
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::detail
|
||||||
{
|
|
||||||
|
|
||||||
namespace detail
|
|
||||||
{
|
{
|
||||||
|
|
||||||
// helper for bitwise and for 1 byte
|
// helper for bitwise and for 1 byte
|
||||||
@@ -139,6 +136,4 @@ constexpr size_t __bit_xor(void* dst, const void* src, size_t n) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_LANG_DETAIL_BITS_H
|
#endif // FENNEC_LANG_DETAIL_BITS_H
|
||||||
|
|||||||
@@ -22,10 +22,7 @@
|
|||||||
#include <fennec/lang/types.h>
|
#include <fennec/lang/types.h>
|
||||||
#include <fennec/lang/type_transforms.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> {};
|
||||||
@@ -59,6 +56,4 @@ template<> struct __make_signed<ullong_t> : type_identity<llong_t> {};
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_LANG_DETAIL_NUMERIC_TRANSFORMS_H
|
#endif // FENNEC_LANG_DETAIL_NUMERIC_TRANSFORMS_H
|
||||||
|
|||||||
@@ -21,16 +21,20 @@
|
|||||||
|
|
||||||
#include <fennec/lang/type_transforms.h>
|
#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
|
#endif // FENNEC_LANG_DETAIL_TYPE_SEQUENCES_H
|
||||||
|
|||||||
@@ -22,10 +22,7 @@
|
|||||||
#include <fennec/lang/constants.h>
|
#include <fennec/lang/constants.h>
|
||||||
#include <fennec/lang/float.h>
|
#include <fennec/lang/float.h>
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::detail
|
||||||
{
|
|
||||||
|
|
||||||
namespace detail
|
|
||||||
{
|
{
|
||||||
|
|
||||||
// Nothing interesting to note here
|
// Nothing interesting to note here
|
||||||
@@ -68,7 +65,10 @@ template<> struct __is_floating_point<double_t> : true_type {};
|
|||||||
template<typename> struct __is_pointer : false_type {};
|
template<typename> struct __is_pointer : false_type {};
|
||||||
template<typename T> struct __is_pointer<T*> : true_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> {};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,7 @@
|
|||||||
|
|
||||||
#include <fennec/lang/types.h>
|
#include <fennec/lang/types.h>
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::detail
|
||||||
{
|
|
||||||
|
|
||||||
namespace detail
|
|
||||||
{
|
{
|
||||||
|
|
||||||
template<typename _Tp, typename = void>
|
template<typename _Tp, typename = void>
|
||||||
@@ -50,6 +47,4 @@ struct __add_rvalue_reference<_Tp, void_t<_Tp&&>> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_LANG_DETAIL_TYPE_TRANSFORMS_H
|
#endif // FENNEC_LANG_DETAIL_TYPE_TRANSFORMS_H
|
||||||
|
|||||||
112
include/fennec/lang/type_operators.h
Normal file
112
include/fennec/lang/type_operators.h
Normal 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
|
||||||
@@ -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<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`
|
/// \brief Take a Template with a Pack `ClassT<ArgsT...>` and replace the first `ArgT` of `ArgsT...` with `SubT`
|
||||||
|
|||||||
@@ -112,6 +112,14 @@
|
|||||||
namespace fennec
|
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 =====================================================================================================
|
// fennec::is_void =====================================================================================================
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -20,32 +20,29 @@
|
|||||||
#ifndef FENNEC_MATH_SWIZZLE_STORAGE_H
|
#ifndef FENNEC_MATH_SWIZZLE_STORAGE_H
|
||||||
#define 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
|
||||||
/// \brief Backing storage struct for \ref fennec::swizzle "swizzle"
|
// \tparam IndicesV Swizzle Order
|
||||||
/// \tparam DataT Data Type
|
|
||||||
/// \tparam ScalarT Element Types
|
|
||||||
/// \tparam IndicesV Swizzle Order
|
|
||||||
template<typename DataT, typename ScalarT, size_t...IndicesV>
|
template<typename DataT, typename ScalarT, size_t...IndicesV>
|
||||||
struct swizzle_storage
|
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... };
|
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;
|
DataT data;
|
||||||
|
|
||||||
///
|
//
|
||||||
/// \brief element access, returns a copy of the value at index \p i
|
// \brief element access, returns a copy of the value at index \p i
|
||||||
/// \param i the index
|
// \param i the index
|
||||||
/// \returns a copy of the scalar value at index \p i
|
// \returns a copy of the scalar value at index \p i
|
||||||
constexpr ScalarT operator[](size_t i) const noexcept {
|
constexpr ScalarT operator[](size_t i) const noexcept {
|
||||||
return data[indices[i]];
|
return data[indices[i]];
|
||||||
}
|
}
|
||||||
@@ -53,7 +50,5 @@ struct swizzle_storage
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // FENNEC_MATH_SWIZZLE_STORAGE_H
|
#endif // FENNEC_MATH_SWIZZLE_STORAGE_H
|
||||||
|
|||||||
@@ -27,65 +27,60 @@
|
|||||||
|
|
||||||
#include <fennec/containers/array.h>
|
#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>
|
template<typename scalar, size_t size>
|
||||||
struct vector_base_type_helper
|
struct vector_base_type_helper
|
||||||
{
|
{
|
||||||
///
|
//
|
||||||
/// \var SizeV
|
// \var SizeV
|
||||||
/// \brief size of the vector type
|
// \brief size of the vector type
|
||||||
inline static constexpr size_t SizeV = size;
|
inline static constexpr size_t SizeV = size;
|
||||||
|
|
||||||
|
|
||||||
///
|
//
|
||||||
/// \brief Base scalar type
|
// \brief Base scalar type
|
||||||
using ScalarT = scalar;
|
using ScalarT = scalar;
|
||||||
|
|
||||||
///
|
//
|
||||||
/// \brief Base vector type
|
// \brief Base vector type
|
||||||
using VectorT = vec<ScalarT, SizeV>;
|
using VectorT = vec<ScalarT, SizeV>;
|
||||||
|
|
||||||
///
|
//
|
||||||
/// \brief Backing array holding the elements
|
// \brief Backing array holding the elements
|
||||||
using DataT = array<ScalarT, SizeV>;
|
using DataT = array<ScalarT, SizeV>;
|
||||||
|
|
||||||
///
|
//
|
||||||
/// \brief Helper for generating a swizzle from a set of indices
|
// \brief Helper for generating a swizzle from a set of indices
|
||||||
/// \tparam IndicesV Indices of the vector to pull from
|
// \tparam IndicesV Indices of the vector to pull from
|
||||||
template<size_t...IndicesV> struct SwizzleGen
|
template<size_t...IndicesV> struct SwizzleGen
|
||||||
{
|
{
|
||||||
/// \brief generated swizzle type
|
// \brief generated swizzle type
|
||||||
using type = swizzle<VectorT, DataT, ScalarT, IndicesV...>;
|
using type = swizzle<VectorT, DataT, ScalarT, IndicesV...>;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Specialization for single component swizzles to decay into a scalar
|
// Specialization for single component swizzles to decay into a scalar
|
||||||
template<size_t IndexV> struct SwizzleGen<IndexV>
|
template<size_t IndexV> struct SwizzleGen<IndexV>
|
||||||
{
|
{
|
||||||
/// \brief decayed scalar type
|
// \brief decayed scalar type
|
||||||
using type = ScalarT;
|
using type = ScalarT;
|
||||||
};
|
};
|
||||||
|
|
||||||
///
|
//
|
||||||
/// \brief backing storage type
|
// \brief backing storage type
|
||||||
using StorageT = vector_storage<SizeV, SwizzleGen, DataT>;
|
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>
|
template<typename ScalarT, size_t SizeV>
|
||||||
using vector_base_type = typename vector_base_type_helper<ScalarT, SizeV>::StorageT;
|
using vector_base_type = typename vector_base_type_helper<ScalarT, SizeV>::StorageT;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_MATH_VECTOR_BASE_H
|
#endif // FENNEC_MATH_VECTOR_BASE_H
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#ifndef FENNEC_MATH_VECTOR_STORAGE_H
|
#ifndef FENNEC_MATH_VECTOR_STORAGE_H
|
||||||
#define FENNEC_MATH_VECTOR_STORAGE_H
|
#define FENNEC_MATH_VECTOR_STORAGE_H
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#if FENNEC_COMPILER_GCC
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||||
#endif
|
#endif
|
||||||
@@ -30,17 +30,14 @@
|
|||||||
#pragma warning(disable:4201)
|
#pragma warning(disable:4201)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::detail
|
||||||
{
|
{
|
||||||
|
|
||||||
namespace detail
|
//
|
||||||
{
|
// \brief backing storage type for vectors
|
||||||
|
// \tparam SizeV size of the vector
|
||||||
///
|
// \tparam SwizzleGenT generator for swizzles
|
||||||
/// \brief backing storage type for vectors
|
// \tparam DataT backing data type
|
||||||
/// \tparam SizeV size of the vector
|
|
||||||
/// \tparam SwizzleGenT generator for swizzles
|
|
||||||
/// \tparam DataT backing data type
|
|
||||||
template<size_t SizeV, template<size_t...> class SwizzleGenT, typename DataT> struct vector_storage;
|
template<size_t SizeV, template<size_t...> class SwizzleGenT, typename DataT> struct vector_storage;
|
||||||
|
|
||||||
|
|
||||||
@@ -72,8 +69,8 @@ struct vector_storage<1, SwizzleGenT, DataT>
|
|||||||
template <template <size_t...> class SwizzleGenT, typename DataT>
|
template <template <size_t...> class SwizzleGenT, typename DataT>
|
||||||
struct vector_storage<2, SwizzleGenT, DataT>
|
struct vector_storage<2, SwizzleGenT, DataT>
|
||||||
{
|
{
|
||||||
///
|
//
|
||||||
/// alias to allow for increased legibility
|
// alias to allow for increased legibility
|
||||||
template<size_t...IndicesV> using swizzle = typename SwizzleGenT<IndicesV...>::type;
|
template<size_t...IndicesV> using swizzle = typename SwizzleGenT<IndicesV...>::type;
|
||||||
|
|
||||||
vector_storage() = default;
|
vector_storage() = default;
|
||||||
@@ -609,8 +606,6 @@ struct vector_storage<4, SwizzleGenT, DataT>
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -467,7 +467,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Allocation and Deallocation =========================================================================================
|
// Allocation and Deallocation =====================================================================================
|
||||||
|
|
||||||
///
|
///
|
||||||
/// \brief Allocate a block of memory for the allocation.
|
/// \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.
|
/// \brief Release the block of memory.
|
||||||
constexpr void deallocate() noexcept {
|
constexpr void deallocate() noexcept {
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public:
|
|||||||
/// \returns a reference to the byte at `i`
|
/// \returns a reference to the byte at `i`
|
||||||
constexpr byte_t& operator[](int i) {
|
constexpr byte_t& operator[](int i) {
|
||||||
assertd(not _const, "Attempted to Access Const-Qualified Memory as Non-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 _arr[i];
|
return _arr[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ public:
|
|||||||
/// \returns a copy of the byte at `i`
|
/// \returns a copy of the byte at `i`
|
||||||
constexpr byte_t operator[](int i) const {
|
constexpr byte_t operator[](int i) const {
|
||||||
assertd(not _const, "Attempted to Access Const-Qualified Memory as Non-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];
|
return _carr[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ public:
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr const T* cast() const {
|
constexpr const T* cast() const {
|
||||||
const void* temp = _carr;
|
const void* temp = _carr;
|
||||||
return static_cast<T*>(temp);
|
return static_cast<const T*>(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -139,7 +139,7 @@ private:
|
|||||||
/// \brief Byte Array Hash Function
|
/// \brief Byte Array Hash Function
|
||||||
template<>
|
template<>
|
||||||
struct hash<byte_array> {
|
struct hash<byte_array> {
|
||||||
size_t operator()(const byte_array& bytes) {
|
size_t operator()(const byte_array& bytes) const {
|
||||||
|
|
||||||
// Murmur2
|
// Murmur2
|
||||||
static constexpr uint64_t m = 0xc6a4a7935bd1e995;
|
static constexpr uint64_t m = 0xc6a4a7935bd1e995;
|
||||||
@@ -148,7 +148,7 @@ struct hash<byte_array> {
|
|||||||
const uint64_t n = bytes.size();
|
const uint64_t n = bytes.size();
|
||||||
|
|
||||||
uint64_t h = s ^ (n * m);
|
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));
|
const uint64_t* y = x + (n / sizeof(uint64_t));
|
||||||
|
|
||||||
while (x != y) {
|
while (x != y) {
|
||||||
@@ -164,15 +164,16 @@ struct hash<byte_array> {
|
|||||||
|
|
||||||
const uint8_t* b = (const uint8_t*)x;
|
const uint8_t* b = (const uint8_t*)x;
|
||||||
switch (n & 7) {
|
switch (n & 7) {
|
||||||
case 7: h ^= uint64_t(b[6]) << 48;
|
case 7: h ^= uint64_t(b[6]) << 48; __attribute__((fallthrough));
|
||||||
case 6: h ^= uint64_t(b[5]) << 40;
|
case 6: h ^= uint64_t(b[5]) << 40; __attribute__((fallthrough));
|
||||||
case 5: h ^= uint64_t(b[4]) << 32;
|
case 5: h ^= uint64_t(b[4]) << 32; __attribute__((fallthrough));
|
||||||
case 4: h ^= uint64_t(b[3]) << 24;
|
case 4: h ^= uint64_t(b[3]) << 24; __attribute__((fallthrough));
|
||||||
case 3: h ^= uint64_t(b[2]) << 16;
|
case 3: h ^= uint64_t(b[2]) << 16; __attribute__((fallthrough));
|
||||||
case 2: h ^= uint64_t(b[1]) << 8;
|
case 2: h ^= uint64_t(b[1]) << 8; __attribute__((fallthrough));
|
||||||
case 1: h ^= uint64_t(b[0]);
|
case 1: h ^= uint64_t(b[0]);
|
||||||
h *= m;
|
h *= m;
|
||||||
default:
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
h ^= h >> r;
|
h ^= h >> r;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
///
|
///
|
||||||
/// \file memory.h
|
/// \file memory.h
|
||||||
/// \brief \ref
|
/// \brief \ref fennec_memory
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
/// \details
|
/// \details
|
||||||
@@ -32,17 +32,9 @@
|
|||||||
#define FENNEC_MEMORY_MEMORY_H
|
#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.
|
/// This library implements functions and data structures to memory management and manipulation
|
||||||
///
|
|
||||||
/// - \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
|
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
|
|
||||||
|
|||||||
@@ -921,7 +921,7 @@ bool file::eof() const {
|
|||||||
|
|
||||||
char file::getc() {
|
char file::getc() {
|
||||||
assert(_error == nullptr, "Attempted an Operation on a File in an Errored State");
|
assert(_error == nullptr, "Attempted an Operation on a File in an Errored State");
|
||||||
assert(not _mode & fmode_wide, "Attempted Byte Operation on Wide File");
|
assert(not(_mode & fmode_wide), "Attempted Byte Operation on Wide File");
|
||||||
|
|
||||||
// Check if there is a file
|
// Check if there is a file
|
||||||
if (_handle == nullptr) {
|
if (_handle == nullptr) {
|
||||||
@@ -961,7 +961,7 @@ size_t file::read(void* data, size_t size, size_t n) {
|
|||||||
|
|
||||||
string file::getline() {
|
string file::getline() {
|
||||||
assert(_error == nullptr, "Attempted an Operation on a File in an Errored State");
|
assert(_error == nullptr, "Attempted an Operation on a File in an Errored State");
|
||||||
assert(not _mode & fmode_wide, "Attempted Byte Operation on Wide File");
|
assert(not(_mode & fmode_wide), "Attempted Byte Operation on Wide File");
|
||||||
|
|
||||||
// Check if there is a file
|
// Check if there is a file
|
||||||
if (_handle == nullptr) {
|
if (_handle == nullptr) {
|
||||||
@@ -1011,7 +1011,7 @@ wstring file::getwline() {
|
|||||||
|
|
||||||
bool file::putc(char c) {
|
bool file::putc(char c) {
|
||||||
assert(_error == nullptr, "Attempted an Operation on a File in an Errored State");
|
assert(_error == nullptr, "Attempted an Operation on a File in an Errored State");
|
||||||
assert(not _mode & fmode_wide, "Attempted Byte Operation on Wide File");
|
assert(not(_mode & fmode_wide), "Attempted Byte Operation on Wide File");
|
||||||
|
|
||||||
// Check if there is a file
|
// Check if there is a file
|
||||||
if (_handle == nullptr) {
|
if (_handle == nullptr) {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ wayland_display::wayland_display(linux_platform* platform, const cstring& drv)
|
|||||||
, _handle()
|
, _handle()
|
||||||
, _platform(platform) {
|
, _platform(platform) {
|
||||||
load_symbols(_platform);
|
load_symbols(_platform);
|
||||||
_handle = wl_display_connect(nullptr);
|
_handle = wl_display_connect(drv);
|
||||||
}
|
}
|
||||||
|
|
||||||
wayland_display::~wayland_display() {
|
wayland_display::~wayland_display() {
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ add_executable(fennec-test main.cpp
|
|||||||
tests/lang/test_hashing.h
|
tests/lang/test_hashing.h
|
||||||
tests/containers/test_array.h
|
tests/containers/test_array.h
|
||||||
tests/containers/test_set.h
|
tests/containers/test_set.h
|
||||||
|
tests/containers/test_map.h
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_definitions(fennec-test PUBLIC FENNEC_TEST_CWD="${CMAKE_SOURCE_DIR}/bin/${FENNEC_BUILD_NAME}"
|
target_compile_definitions(fennec-test PUBLIC FENNEC_TEST_CWD="${CMAKE_SOURCE_DIR}/bin/${FENNEC_BUILD_NAME}"
|
||||||
|
|||||||
@@ -23,10 +23,7 @@
|
|||||||
|
|
||||||
#include <fennec/containers/array.h>
|
#include <fennec/containers/array.h>
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void fennec_test_containers_array() {
|
inline void fennec_test_containers_array() {
|
||||||
@@ -44,6 +41,4 @@ inline void fennec_test_containers_array() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_CONTAINERS_ARRAY_H
|
#endif // FENNEC_TEST_CONTAINERS_ARRAY_H
|
||||||
|
|||||||
@@ -23,10 +23,7 @@
|
|||||||
|
|
||||||
#include <fennec/containers/dynarray.h>
|
#include <fennec/containers/dynarray.h>
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void fennec_test_containers_dynarray() {
|
inline void fennec_test_containers_dynarray() {
|
||||||
@@ -50,6 +47,4 @@ inline void fennec_test_containers_dynarray() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_CONTAINERS_DYNARRAY_H
|
#endif // FENNEC_TEST_CONTAINERS_DYNARRAY_H
|
||||||
|
|||||||
41
test/tests/containers/test_map.h
Normal file
41
test/tests/containers/test_map.h
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
// =====================================================================================================================
|
||||||
|
// 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_TEST_CONTAINERS_MAP_H
|
||||||
|
#define FENNEC_TEST_CONTAINERS_MAP_H
|
||||||
|
|
||||||
|
#include <fennec/containers/map.h>
|
||||||
|
#include <fennec/fproc/strings/string.h>
|
||||||
|
|
||||||
|
namespace fennec::test {
|
||||||
|
|
||||||
|
inline void fennec_test_containers_map() {
|
||||||
|
map<string, string> map;
|
||||||
|
|
||||||
|
map.emplace("Hello", "World");
|
||||||
|
|
||||||
|
fennec_test_run(*map["Hello"], string("World"));
|
||||||
|
|
||||||
|
map.erase("Hello");
|
||||||
|
|
||||||
|
fennec_test_run(map["Hello"], static_cast<string*>(nullptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // FENNEC_TEST_CONTAINERS_MAP_H
|
||||||
@@ -23,10 +23,7 @@
|
|||||||
|
|
||||||
#include <fennec/containers/optional.h>
|
#include <fennec/containers/optional.h>
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
enum opt_test_ : uint8_t {
|
enum opt_test_ : uint8_t {
|
||||||
@@ -86,30 +83,48 @@ inline void fennec_test_containers_optional() {
|
|||||||
optional_helper::test = opt_test_default_constructor;
|
optional_helper::test = opt_test_default_constructor;
|
||||||
opt.emplace();
|
opt.emplace();
|
||||||
|
|
||||||
|
fennec_test_spacer(1);
|
||||||
|
|
||||||
optional_helper::test = opt_test_destructor;
|
optional_helper::test = opt_test_destructor;
|
||||||
opt.reset();
|
opt.reset();
|
||||||
|
|
||||||
|
fennec_test_spacer(1);
|
||||||
|
|
||||||
optional_helper::test = opt_test_default_constructor | opt_test_copy_constructor | opt_test_destructor;
|
optional_helper::test = opt_test_default_constructor | opt_test_copy_constructor | opt_test_destructor;
|
||||||
opt = copy(optional_helper());
|
opt = copy(optional_helper());
|
||||||
|
|
||||||
|
fennec_test_spacer(1);
|
||||||
|
|
||||||
optional_helper::test = opt_test_destructor;
|
optional_helper::test = opt_test_destructor;
|
||||||
opt.reset();
|
opt.reset();
|
||||||
|
|
||||||
|
fennec_test_spacer(1);
|
||||||
|
|
||||||
optional_helper::test = opt_test_default_constructor | opt_test_move_constructor | opt_test_destructor;
|
optional_helper::test = opt_test_default_constructor | opt_test_move_constructor | opt_test_destructor;
|
||||||
opt = optional_helper();
|
opt = optional_helper();
|
||||||
|
|
||||||
|
fennec_test_spacer(1);
|
||||||
|
|
||||||
optional_helper::test = opt_test_destructor;
|
optional_helper::test = opt_test_destructor;
|
||||||
opt.reset();
|
opt.reset();
|
||||||
|
|
||||||
|
fennec_test_spacer(1);
|
||||||
|
|
||||||
optional_helper::test = opt_test_default_constructor;
|
optional_helper::test = opt_test_default_constructor;
|
||||||
opt.emplace();
|
opt.emplace();
|
||||||
|
|
||||||
|
fennec_test_spacer(1);
|
||||||
|
|
||||||
optional_helper::test = opt_test_default_constructor | opt_test_copy_assignment | opt_test_destructor;
|
optional_helper::test = opt_test_default_constructor | opt_test_copy_assignment | opt_test_destructor;
|
||||||
opt = copy(optional_helper());
|
opt = copy(optional_helper());
|
||||||
|
|
||||||
|
fennec_test_spacer(1);
|
||||||
|
|
||||||
optional_helper::test = opt_test_default_constructor | opt_test_move_assignment | opt_test_destructor;
|
optional_helper::test = opt_test_default_constructor | opt_test_move_assignment | opt_test_destructor;
|
||||||
opt = optional_helper();
|
opt = optional_helper();
|
||||||
|
|
||||||
|
fennec_test_spacer(1);
|
||||||
|
|
||||||
optional_helper::test = opt_test_destructor;
|
optional_helper::test = opt_test_destructor;
|
||||||
opt.reset();
|
opt.reset();
|
||||||
|
|
||||||
@@ -119,6 +134,4 @@ inline void fennec_test_containers_optional() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_CONTAINERS_OPTIONAL_H
|
#endif // FENNEC_TEST_CONTAINERS_OPTIONAL_H
|
||||||
|
|||||||
@@ -25,10 +25,7 @@
|
|||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <fennec/containers/set.h>
|
#include <fennec/containers/set.h>
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void fennec_test_containers_set() {
|
inline void fennec_test_containers_set() {
|
||||||
@@ -53,6 +50,4 @@ inline void fennec_test_containers_set() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_CONTAINERS_SET_H
|
#endif // FENNEC_TEST_CONTAINERS_SET_H
|
||||||
|
|||||||
@@ -21,10 +21,7 @@
|
|||||||
|
|
||||||
#include <fennec/fproc/strings/cstring.h>
|
#include <fennec/fproc/strings/cstring.h>
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void fennec_test_fproc_strings_cstring()
|
inline void fennec_test_fproc_strings_cstring()
|
||||||
@@ -51,6 +48,4 @@ inline void fennec_test_fproc_strings_cstring()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_FPROC_STRINGS_CSTRING_H
|
#endif // FENNEC_TEST_FPROC_STRINGS_CSTRING_H
|
||||||
|
|||||||
@@ -24,10 +24,7 @@
|
|||||||
#include <fennec/fproc/filesystem/file.h>
|
#include <fennec/fproc/filesystem/file.h>
|
||||||
#include <fennec/fproc/filesystem/path.h>
|
#include <fennec/fproc/filesystem/path.h>
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void fennec_test_fproc_io() {
|
inline void fennec_test_fproc_io() {
|
||||||
@@ -92,6 +89,4 @@ inline void fennec_test_fproc_io() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_FPROC_IO_H
|
#endif // FENNEC_TEST_FPROC_IO_H
|
||||||
|
|||||||
@@ -22,10 +22,7 @@
|
|||||||
#include "../../test.h"
|
#include "../../test.h"
|
||||||
#include "./strings/test_cstring.h"
|
#include "./strings/test_cstring.h"
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void fennec_test_fproc_strings()
|
inline void fennec_test_fproc_strings()
|
||||||
@@ -40,6 +37,4 @@ inline void fennec_test_fproc_strings()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_FPROC_STRINGS_H
|
#endif // FENNEC_TEST_FPROC_STRINGS_H
|
||||||
|
|||||||
@@ -24,10 +24,7 @@
|
|||||||
|
|
||||||
#include "../../test.h"
|
#include "../../test.h"
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void fennec_test_lang_bits()
|
inline void fennec_test_lang_bits()
|
||||||
@@ -44,6 +41,4 @@ inline void fennec_test_lang_bits()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_LANG_BITS_H
|
#endif // FENNEC_TEST_LANG_BITS_H
|
||||||
|
|||||||
@@ -19,10 +19,7 @@
|
|||||||
#ifndef FENNEC_TEST_LANG_CONDITIONAL_TYPES_H
|
#ifndef FENNEC_TEST_LANG_CONDITIONAL_TYPES_H
|
||||||
#define FENNEC_TEST_LANG_CONDITIONAL_TYPES_H
|
#define FENNEC_TEST_LANG_CONDITIONAL_TYPES_H
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void fennec_test_lang_conditional_types()
|
inline void fennec_test_lang_conditional_types()
|
||||||
@@ -32,6 +29,4 @@ inline void fennec_test_lang_conditional_types()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_LANG_CONDITIONAL_TYPES_H
|
#endif // FENNEC_TEST_LANG_CONDITIONAL_TYPES_H
|
||||||
|
|||||||
@@ -22,10 +22,7 @@
|
|||||||
#include <fennec/lang/hashing.h>
|
#include <fennec/lang/hashing.h>
|
||||||
#include "../../test.h"
|
#include "../../test.h"
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void fennec_test_lang_hashing() {
|
inline void fennec_test_lang_hashing() {
|
||||||
@@ -52,6 +49,4 @@ inline void fennec_test_lang_hashing() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_LANG_HASHING_H
|
#endif // FENNEC_TEST_LANG_HASHING_H
|
||||||
|
|||||||
@@ -21,10 +21,7 @@
|
|||||||
|
|
||||||
#include <fennec/lang/sequences.h>
|
#include <fennec/lang/sequences.h>
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void test_sequences()
|
inline void test_sequences()
|
||||||
@@ -38,6 +35,4 @@ inline void test_sequences()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_LANG_SEQUENCES_H
|
#endif // FENNEC_TEST_LANG_SEQUENCES_H
|
||||||
|
|||||||
@@ -23,10 +23,7 @@
|
|||||||
|
|
||||||
#include "../../../test.h"
|
#include "../../../test.h"
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void fennec_test_math_quaternion() {
|
inline void fennec_test_math_quaternion() {
|
||||||
@@ -44,6 +41,4 @@ inline void fennec_test_math_quaternion() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_MATH_EXT_QUATERNION_H
|
#endif // FENNEC_TEST_MATH_EXT_QUATERNION_H
|
||||||
|
|||||||
@@ -21,10 +21,7 @@
|
|||||||
|
|
||||||
#include "../../test.h"
|
#include "../../test.h"
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void fennec_test_math_common()
|
inline void fennec_test_math_common()
|
||||||
@@ -212,6 +209,4 @@ inline void fennec_test_math_common()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_MATH_COMMON_H
|
#endif // FENNEC_TEST_MATH_COMMON_H
|
||||||
|
|||||||
@@ -24,10 +24,7 @@
|
|||||||
#include <fennec/math/exponential.h>
|
#include <fennec/math/exponential.h>
|
||||||
#include <fennec/math/ext/constants.h>
|
#include <fennec/math/ext/constants.h>
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void fennec_test_math_exponential()
|
inline void fennec_test_math_exponential()
|
||||||
@@ -79,6 +76,4 @@ inline void fennec_test_math_exponential()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_MATH_EXPONENTIAL_H
|
#endif // FENNEC_TEST_MATH_EXPONENTIAL_H
|
||||||
|
|||||||
@@ -23,10 +23,7 @@
|
|||||||
#ifndef FENNEC_TEST_MATH_EXT_H
|
#ifndef FENNEC_TEST_MATH_EXT_H
|
||||||
#define FENNEC_TEST_MATH_EXT_H
|
#define FENNEC_TEST_MATH_EXT_H
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void fennec_test_math_ext() {
|
inline void fennec_test_math_ext() {
|
||||||
@@ -41,6 +38,4 @@ inline void fennec_test_math_ext() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_MATH_EXT_H
|
#endif // FENNEC_TEST_MATH_EXT_H
|
||||||
|
|||||||
@@ -25,10 +25,7 @@
|
|||||||
|
|
||||||
#include "../../test.h"
|
#include "../../test.h"
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void fennec_test_math_geometric()
|
inline void fennec_test_math_geometric()
|
||||||
@@ -81,7 +78,5 @@ inline void fennec_test_math_geometric()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_GEOMETRIC_H
|
#endif // FENNEC_TEST_GEOMETRIC_H
|
||||||
|
|||||||
@@ -26,10 +26,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void fennec_test_math_matrix()
|
inline void fennec_test_math_matrix()
|
||||||
@@ -324,6 +321,4 @@ inline void fennec_test_math_matrix()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_MATRIX_H
|
#endif // FENNEC_TEST_MATRIX_H
|
||||||
|
|||||||
@@ -20,10 +20,7 @@
|
|||||||
#define FENNEC_TEST_MATH_RELATIONAL_H
|
#define FENNEC_TEST_MATH_RELATIONAL_H
|
||||||
#include "../../test.h"
|
#include "../../test.h"
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void fennec_test_math_relational()
|
inline void fennec_test_math_relational()
|
||||||
@@ -49,6 +46,4 @@ inline void fennec_test_math_relational()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_MATH_RELATIONAL_H
|
#endif // FENNEC_TEST_MATH_RELATIONAL_H
|
||||||
|
|||||||
@@ -24,10 +24,7 @@
|
|||||||
|
|
||||||
#include "../../test.h"
|
#include "../../test.h"
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void fennec_test_math_scalar()
|
inline void fennec_test_math_scalar()
|
||||||
@@ -69,6 +66,4 @@ inline void fennec_test_math_scalar()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_SCALAR_H
|
#endif // FENNEC_TEST_SCALAR_H
|
||||||
|
|||||||
@@ -23,10 +23,7 @@
|
|||||||
|
|
||||||
#include "../../test.h"
|
#include "../../test.h"
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void fennec_test_math_trigonometric()
|
inline void fennec_test_math_trigonometric()
|
||||||
@@ -116,6 +113,4 @@ inline void fennec_test_math_trigonometric()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_MATH_TRIGONOMETRIC_H
|
#endif // FENNEC_TEST_MATH_TRIGONOMETRIC_H
|
||||||
|
|||||||
@@ -26,10 +26,7 @@
|
|||||||
|
|
||||||
#include "../../test.h"
|
#include "../../test.h"
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void fennec_test_math_vector()
|
inline void fennec_test_math_vector()
|
||||||
@@ -598,6 +595,4 @@ inline void fennec_test_math_vector()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_VECTOR_H
|
#endif // FENNEC_TEST_VECTOR_H
|
||||||
|
|||||||
@@ -22,10 +22,7 @@
|
|||||||
#include "../../../test.h"
|
#include "../../../test.h"
|
||||||
#include <fennec/platform/linux/wayland/display.h>
|
#include <fennec/platform/linux/wayland/display.h>
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
using namespace wayland;
|
using namespace wayland;
|
||||||
@@ -38,6 +35,4 @@ inline void fennec_test_platform_linux_wayland(linux_platform& platform) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_PLATFORM_LINUX_WAYLAND_H
|
#endif // FENNEC_TEST_PLATFORM_LINUX_WAYLAND_H
|
||||||
|
|||||||
@@ -24,10 +24,7 @@
|
|||||||
#include "linux/test_wayland.h"
|
#include "linux/test_wayland.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void fennec_test_platform_linux() {
|
inline void fennec_test_platform_linux() {
|
||||||
@@ -46,6 +43,4 @@ inline void fennec_test_platform_linux() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_PLATFORM_LINUX_H
|
#endif // FENNEC_TEST_PLATFORM_LINUX_H
|
||||||
|
|||||||
@@ -21,13 +21,11 @@
|
|||||||
|
|
||||||
#include "containers/test_array.h"
|
#include "containers/test_array.h"
|
||||||
#include "containers/test_dynarray.h"
|
#include "containers/test_dynarray.h"
|
||||||
|
#include "containers/test_map.h"
|
||||||
#include "containers/test_optional.h"
|
#include "containers/test_optional.h"
|
||||||
#include "containers/test_set.h"
|
#include "containers/test_set.h"
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void fennec_test_containers()
|
inline void fennec_test_containers()
|
||||||
@@ -50,12 +48,15 @@ inline void fennec_test_containers()
|
|||||||
fennec_test_subheader("set tests");
|
fennec_test_subheader("set tests");
|
||||||
fennec_test_spacer(2);
|
fennec_test_spacer(2);
|
||||||
fennec_test_containers_set();
|
fennec_test_containers_set();
|
||||||
|
fennec_test_spacer(3);
|
||||||
|
|
||||||
|
fennec_test_subheader("map tests");
|
||||||
|
fennec_test_spacer(2);
|
||||||
|
fennec_test_containers_map();
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_CONTAINERS_H
|
#endif // FENNEC_TEST_CONTAINERS_H
|
||||||
|
|||||||
@@ -24,10 +24,7 @@
|
|||||||
#include "./fproc/test_strings.h"
|
#include "./fproc/test_strings.h"
|
||||||
#include "./fproc/test_io.h"
|
#include "./fproc/test_io.h"
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void fennec_test_fproc() {
|
inline void fennec_test_fproc() {
|
||||||
@@ -46,6 +43,4 @@ inline void fennec_test_fproc() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_FPROC_H
|
#endif // FENNEC_TEST_FPROC_H
|
||||||
|
|||||||
@@ -23,10 +23,7 @@
|
|||||||
#include "lang/test_conditional_types.h"
|
#include "lang/test_conditional_types.h"
|
||||||
#include "lang/test_hashing.h"
|
#include "lang/test_hashing.h"
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void fennec_test_lang()
|
inline void fennec_test_lang()
|
||||||
@@ -45,6 +42,4 @@ inline void fennec_test_lang()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_LANG_H
|
#endif // FENNEC_TEST_LANG_H
|
||||||
|
|||||||
@@ -31,10 +31,7 @@
|
|||||||
|
|
||||||
#include "math/test_ext.h"
|
#include "math/test_ext.h"
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void fennec_test_math()
|
inline void fennec_test_math()
|
||||||
@@ -89,6 +86,4 @@ inline void fennec_test_math()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_MATH_H
|
#endif // FENNEC_TEST_MATH_H
|
||||||
|
|||||||
@@ -24,10 +24,7 @@
|
|||||||
#include "./platform/test_linux.h"
|
#include "./platform/test_linux.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec::test
|
||||||
{
|
|
||||||
|
|
||||||
namespace test
|
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void fennec_test_platform() {
|
inline void fennec_test_platform() {
|
||||||
@@ -41,6 +38,4 @@ inline void fennec_test_platform() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FENNEC_TEST_PLATFORM_H
|
#endif // FENNEC_TEST_PLATFORM_H
|
||||||
|
|||||||
Reference in New Issue
Block a user