- Basic RTTI type data with inheritance.
This commit is contained in:
@@ -32,8 +32,8 @@
|
||||
#ifndef FENNEC_CONTAINERS_ARRAY_H
|
||||
#define FENNEC_CONTAINERS_ARRAY_H
|
||||
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/lang/assert.h>
|
||||
#include <fennec/langcpp/types.h>
|
||||
#include <fennec/langcpp/assert.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
#ifndef FENNEC_CONTAINERS_DETAIL_TUPLE_H
|
||||
#define FENNEC_CONTAINERS_DETAIL_TUPLE_H
|
||||
#include <fennec/lang/const_sequences.h>
|
||||
#include <fennec/lang/utility.h>
|
||||
#include <fennec/langcpp/const_sequences.h>
|
||||
#include <fennec/langcpp/utility.h>
|
||||
|
||||
namespace fennec::detail
|
||||
{
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
#ifndef FENNEC_CONTAINERS_DYNARRAY_H
|
||||
#define FENNEC_CONTAINERS_DYNARRAY_H
|
||||
|
||||
#include <fennec/lang/utility.h>
|
||||
#include <initializer_list>
|
||||
#include <fennec/langcpp/utility.h>
|
||||
#include <fennec/memory/allocator.h>
|
||||
#include <fennec/memory/new.h>
|
||||
|
||||
@@ -60,7 +61,7 @@ namespace fennec
|
||||
///
|
||||
/// \tparam TypeT value type
|
||||
template<class TypeT, class Alloc = allocator<TypeT>>
|
||||
class dynarray {
|
||||
struct dynarray {
|
||||
public:
|
||||
|
||||
// Definitions =========================================================================================================
|
||||
@@ -174,6 +175,51 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Array Copy Constructor
|
||||
/// \tparam N The length of the array, automatically deduced
|
||||
/// \param arr The array to copy
|
||||
template<size_t N>
|
||||
constexpr dynarray(const TypeT (&arr)[N])
|
||||
: _alloc(N)
|
||||
, _size(N) {
|
||||
for (size_t i = 0; i < N; ++i) {
|
||||
_alloc[i] = arr[i];
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Array Move Constructor
|
||||
/// \tparam N The length of the array, automatically deduced
|
||||
/// \param arr The array to move
|
||||
template<size_t N>
|
||||
constexpr dynarray(TypeT (&&arr)[N])
|
||||
: _alloc(N)
|
||||
, _size(N) {
|
||||
for (size_t i = 0; i < N; ++i) {
|
||||
_alloc[i] = fennec::move(arr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename OTypeT, class OAlloc>
|
||||
constexpr dynarray(const dynarray<OTypeT, OAlloc>& conv)
|
||||
: _alloc(conv.size())
|
||||
, _size(conv.size()) {
|
||||
size_t i = 0;
|
||||
for (const auto& it : conv) {
|
||||
fennec::construct(&_alloc[i++], it);
|
||||
}
|
||||
}
|
||||
|
||||
constexpr dynarray(std::initializer_list<value_t> l, const alloc_t& alloc = alloc_t())
|
||||
: _alloc(l.size(), alloc)
|
||||
, _size(l.size()) {
|
||||
size_t i = 0;
|
||||
for (auto& it : l) {
|
||||
fennec::construct(&_alloc[i++], fennec::move(it));
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Copy Constructor, uses the copy constructor to copy each element
|
||||
/// \param arr the dynarray to copy
|
||||
@@ -236,6 +282,36 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Array Copy Assignment Operator
|
||||
/// \tparam N the length of the array
|
||||
/// \param arr the array to copy
|
||||
/// \returns A dynarray after having copied each element of `arr`
|
||||
template<size_t N>
|
||||
constexpr dynarray& operator=(const TypeT (&arr)[N]) {
|
||||
this->clear();
|
||||
_alloc.creallocate(_size = N);
|
||||
for (size_t i = 0; i < _size; ++i) {
|
||||
fennec::construct(&_alloc[i], fennec::copy(arr[i]));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Array Copy Assignment Operator
|
||||
/// \tparam N the length of the array
|
||||
/// \param arr the array to copy
|
||||
/// \returns A dynarray after having moved each element of `arr`
|
||||
template<size_t N>
|
||||
constexpr dynarray& operator=(TypeT (&&arr)[N]) {
|
||||
this->clear();
|
||||
_alloc.creallocate(_size = N);
|
||||
for (size_t i = 0; i < _size; ++i) {
|
||||
fennec::construct(&_alloc[i], fennec::move(arr[i]));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
||||
// Properties ==========================================================================================================
|
||||
|
||||
@@ -291,7 +291,9 @@ private:
|
||||
~U() {
|
||||
fennec::destruct(&root);
|
||||
}
|
||||
} trick = { .root = { KeyT(fennec::forward<ArgsT>(args)...), 0 } };
|
||||
} trick = {
|
||||
.root = { KeyT(fennec::forward<ArgsT>(args)...), 0 }
|
||||
};
|
||||
return _set.find(trick.val);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,10 +31,10 @@
|
||||
#ifndef FENNEC_CONTAINERS_OPTIONAL_H
|
||||
#define FENNEC_CONTAINERS_OPTIONAL_H
|
||||
|
||||
#include <fennec/lang/utility.h>
|
||||
#include <fennec/langcpp/utility.h>
|
||||
#include <fennec/memory/new.h>
|
||||
|
||||
#include <fennec/lang/assert.h>
|
||||
#include <fennec/langcpp/assert.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
#define FENNEC_CONTAINERS_PAIR_H
|
||||
|
||||
#include <fennec/containers/tuple.h>
|
||||
#include <fennec/lang/hashing.h>
|
||||
#include <fennec/lang/utility.h>
|
||||
#include <fennec/langcpp/hashing.h>
|
||||
#include <fennec/langcpp/utility.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
#define FENNEC_CONTAINERS_PRIORITY_QUEUE_H
|
||||
|
||||
#include <fennec/containers/object_pool.h>
|
||||
#include <fennec/lang/compare.h>
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/langcpp/compare.h>
|
||||
#include <fennec/langcpp/types.h>
|
||||
#include <fennec/memory/allocator.h>
|
||||
|
||||
// Binary heaps are just kinda busted.
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
#include <fennec/containers/list.h>
|
||||
#include <fennec/containers/optional.h>
|
||||
#include <fennec/containers/traversal.h>
|
||||
#include <fennec/containers/pair.h>
|
||||
|
||||
#include <fennec/memory/allocator.h>
|
||||
|
||||
namespace fennec
|
||||
@@ -194,7 +196,7 @@ public:
|
||||
/// \param i The id of the node to check
|
||||
/// \returns The id of the child node
|
||||
constexpr size_t child(size_t i, size_t n = 0) const {
|
||||
if (i >= _table.capacity()) return npos;
|
||||
if (i >= _table.capacity() && n != npos) return npos;
|
||||
size_t c = i == npos ? npos : _table[i].child;
|
||||
if (n != 0)
|
||||
return next(c, n == npos ? npos : n - 1);
|
||||
@@ -205,7 +207,7 @@ public:
|
||||
/// \param i The id of the node to check
|
||||
/// \returns The id of the next node
|
||||
constexpr size_t next(size_t i, size_t n = 0) const {
|
||||
if (i >= _table.capacity()) return npos;
|
||||
if (i >= _table.capacity() && n != npos) return npos;
|
||||
if (i == npos) {
|
||||
return npos;
|
||||
}
|
||||
@@ -332,7 +334,7 @@ public:
|
||||
///
|
||||
/// \brief Insertion, creates a node in the tree with parent `parent`
|
||||
/// \param parent the parent node, if `npos` sets the value of the root node
|
||||
/// \param next the next node, as an index relative to the parent
|
||||
/// \param next the next node, as an index relative to the parent, i.e. parent[0] == parent.child, parent[1] == parent.child.next
|
||||
/// \param val the value to insert
|
||||
/// \returns the index of the created node
|
||||
constexpr size_t insert(size_t parent, size_t next, const value_t& val) {
|
||||
@@ -349,10 +351,33 @@ public:
|
||||
return this->_insert(parent, next, fennec::forward<value_t>(val));
|
||||
}
|
||||
|
||||
constexpr size_t insert(size_t parent, size_t next, const rdtree& tree) {
|
||||
list<pair<size_t, size_t>> visit;
|
||||
visit.push_front({ root, parent });
|
||||
size_t res = npos;
|
||||
|
||||
while (not visit.empty()) {
|
||||
auto node = visit.front();
|
||||
visit.pop_front();
|
||||
|
||||
size_t p = this->_insert(node.second, node.second == parent ? next : npos, tree[node.first]);
|
||||
|
||||
res = (res == npos) ? p : res;
|
||||
|
||||
size_t c = tree.child(node.first, npos);
|
||||
while (c != npos) {
|
||||
visit.push_front({ c, p });
|
||||
c = tree._table[c].prev;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Insertion, creates a node in the tree with parent `parent`
|
||||
/// \param parent the parent node, if `npos` sets the value of the root node
|
||||
/// \param next the next node, as an index relative to the parent
|
||||
/// \param next the next node, as an index relative to the parent, i.e. parent[0] == parent.child, parent[1] == parent.child.next
|
||||
/// \param args the args to construct the value to insert
|
||||
/// \returns the index of the created node
|
||||
template<typename...ArgsT>
|
||||
@@ -390,6 +415,8 @@ public:
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Traversal ===========================================================================================================
|
||||
|
||||
///
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include <fennec/containers/sequence.h>
|
||||
#include <fennec/containers/sequence.h>
|
||||
#include <fennec/containers/sequence.h>
|
||||
#include <fennec/lang/compare.h>
|
||||
#include <fennec/langcpp/compare.h>
|
||||
#include <fennec/memory/allocator.h>
|
||||
|
||||
// https://en.wikipedia.org/wiki/Red%E2%80%93black_tree
|
||||
|
||||
@@ -35,10 +35,10 @@
|
||||
|
||||
#include <fennec/containers/optional.h>
|
||||
#include <fennec/containers/set.h>
|
||||
#include <fennec/lang/compare.h>
|
||||
#include <fennec/langcpp/compare.h>
|
||||
#include <fennec/math/ext/primes.h>
|
||||
#include <fennec/memory/allocator.h>
|
||||
#include <fennec/lang/hashing.h>
|
||||
#include <fennec/langcpp/hashing.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
@@ -330,7 +330,7 @@ public:
|
||||
while (_alloc[i = (i + 1) % capacity()].value) {
|
||||
if (_alloc[i].psl == 0) break;
|
||||
|
||||
fennec::swap(_alloc[i - 1].value, _alloc[i].value);
|
||||
fennec::swap(_alloc[p].value, _alloc[i].value);
|
||||
--_alloc[p].psl, --_sumpsl;
|
||||
p = i;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#define FENNEC_CONTAINERS_TUPLE_H
|
||||
|
||||
#include <fennec/containers/detail/_tuple.h>
|
||||
#include <fennec/lang/type_sequences.h>
|
||||
#include <fennec/langcpp/type_sequences.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
@@ -83,6 +83,8 @@ struct tuple : public detail::_tuple<make_index_sequence_t<sizeof...(TypesT)>, T
|
||||
template<size_t i>
|
||||
using elem_t = typename nth_element<i, TypesT...>::type;
|
||||
|
||||
static constexpr size_t size = sizeof...(TypesT);
|
||||
|
||||
template<typename...ArgsT>
|
||||
tuple(ArgsT&&...args)
|
||||
: base_t(fennec::forward<ArgsT>(args)...) {
|
||||
|
||||
@@ -19,8 +19,10 @@
|
||||
#ifndef FENNEC_CORE_EVENT_H
|
||||
#define FENNEC_CORE_EVENT_H
|
||||
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/lang/typed.h>
|
||||
#include <fennec/langcpp/types.h>
|
||||
#include <fennec/rtti/enable.h>
|
||||
|
||||
#include <fennec/rtti/typeid.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
@@ -37,18 +39,8 @@ public:
|
||||
|
||||
///
|
||||
/// \brief Main event interface, includes static methods for registering listeners and dispatching events
|
||||
struct event : typed<event> {
|
||||
|
||||
// Delete default constructor to enforce type scheme
|
||||
event() = delete;
|
||||
|
||||
///
|
||||
/// \brief Event Constructor, stores the event type
|
||||
/// \tparam EventT The type of the event
|
||||
template<typename EventT>
|
||||
event(EventT* type)
|
||||
: typed(type) {
|
||||
}
|
||||
struct event {
|
||||
virtual ~event() = default;
|
||||
|
||||
///
|
||||
/// \brief Registers a listener for the event type
|
||||
@@ -67,6 +59,8 @@ struct event : typed<event> {
|
||||
static void add_listener(event_listener* listener, uint64_t type);
|
||||
static void remove_listener(event_listener* listener);
|
||||
static void dispatch(event* event);
|
||||
|
||||
FENNEC_RTTI_ENABLE();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#ifndef FENNEC_CORE_SYSTEM_H
|
||||
#define FENNEC_CORE_SYSTEM_H
|
||||
#include <fennec/langproc/strings/string.h>
|
||||
#include <fennec/lang/strings/string.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include <fennec/containers/list.h>
|
||||
#include <fennec/containers/map.h>
|
||||
#include <fennec/containers/priority_queue.h>
|
||||
#include <fennec/langproc/strings/string.h>
|
||||
#include <fennec/lang/strings/string.h>
|
||||
|
||||
//
|
||||
// escape sequences are tricky, sometimes they must be separated by white space,
|
||||
@@ -19,11 +19,11 @@
|
||||
#ifndef FENNEC_LANGPROC_IO_FILE_H
|
||||
#define FENNEC_LANGPROC_IO_FILE_H
|
||||
|
||||
#include <fennec/langproc/filesystem/path.h>
|
||||
#include <fennec/lang/filesystem/path.h>
|
||||
|
||||
#include <fennec/langproc/strings/cstring.h>
|
||||
#include <fennec/langproc/strings/string.h>
|
||||
#include <fennec/langproc/strings/wstring.h>
|
||||
#include <fennec/lang/strings/cstring.h>
|
||||
#include <fennec/lang/strings/string.h>
|
||||
#include <fennec/lang/strings/wstring.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
@@ -19,8 +19,8 @@
|
||||
#ifndef FENNEC_LANGPROC_IO_PATH_H
|
||||
#define FENNEC_LANGPROC_IO_PATH_H
|
||||
|
||||
#include <fennec/langproc/filesystem/path.h>
|
||||
#include <fennec/langproc/strings/string.h>
|
||||
#include <fennec/lang/filesystem/path.h>
|
||||
#include <fennec/lang/strings/string.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
@@ -19,10 +19,10 @@
|
||||
#ifndef FENNEC_LANGPROC_STRINGS_CSTRING_H
|
||||
#define FENNEC_LANGPROC_STRINGS_CSTRING_H
|
||||
|
||||
#include <fennec/langproc/strings/detail/_ctype.h>
|
||||
#include <fennec/lang/strings/detail/_ctype.h>
|
||||
#include <fennec/memory/detail/_string.h>
|
||||
|
||||
#include <fennec/lang/assert.h>
|
||||
#include <fennec/langcpp/assert.h>
|
||||
|
||||
#include <fennec/math/common.h>
|
||||
#include <fennec/memory/bytes.h>
|
||||
@@ -31,8 +31,8 @@
|
||||
#ifndef FENNEC_LANGPROC_STRINGS_FORMAT_H
|
||||
#define FENNEC_LANGPROC_STRINGS_FORMAT_H
|
||||
#include <fennec/containers/pair.h>
|
||||
#include <fennec/langproc/strings/cstring.h>
|
||||
#include <fennec/langproc/strings/string.h>
|
||||
#include <fennec/lang/strings/cstring.h>
|
||||
#include <fennec/lang/strings/string.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
@@ -19,7 +19,7 @@
|
||||
#ifndef FENNEC_LANGPROC_STRINGS_LOCALE_H
|
||||
#define FENNEC_LANGPROC_STRINGS_LOCALE_H
|
||||
|
||||
#include <fennec/langproc/strings/detail/_locale.h>
|
||||
#include <fennec/lang/strings/detail/_locale.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
@@ -19,10 +19,10 @@
|
||||
#ifndef FENNEC_LANGPROC_STRINGS_STRING_H
|
||||
#define FENNEC_LANGPROC_STRINGS_STRING_H
|
||||
|
||||
#include <fennec/langproc/strings/detail/_ctype.h>
|
||||
#include <fennec/langproc/strings/cstring.h>
|
||||
#include <fennec/lang/strings/detail/_ctype.h>
|
||||
#include <fennec/lang/strings/cstring.h>
|
||||
|
||||
#include <fennec/lang/assert.h>
|
||||
#include <fennec/langcpp/assert.h>
|
||||
|
||||
#include <fennec/memory/allocator.h>
|
||||
#include <fennec/memory/common.h>
|
||||
@@ -134,8 +134,14 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr _string& operator=(const _string& str) = default;
|
||||
constexpr _string& operator=(_string&& str) noexcept = default;
|
||||
constexpr _string& operator=(const _string& str) {
|
||||
_str = str._str;
|
||||
return *this;
|
||||
}
|
||||
constexpr _string& operator=(_string&& str) noexcept {
|
||||
_str = fennec::move(str._str);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Properties ==========================================================================================================
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
#ifndef FENNEC_LANGPROC_STRINGS_wcstring_H
|
||||
#define FENNEC_LANGPROC_STRINGS_wcstring_H
|
||||
|
||||
#include <fennec/langproc/strings/detail/_ctype.h>
|
||||
#include <fennec/lang/strings/detail/_ctype.h>
|
||||
#include <fennec/memory/detail/_string.h>
|
||||
|
||||
#include <fennec/lang/assert.h>
|
||||
#include <fennec/langcpp/assert.h>
|
||||
|
||||
#include <fennec/math/common.h>
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
#ifndef FENNEC_LANGPROC_wstringS_WSTRING_H
|
||||
#define FENNEC_LANGPROC_wstringS_WSTRING_H
|
||||
|
||||
#include <fennec/langproc/strings/detail/_ctype.h>
|
||||
#include <fennec/langproc/strings/wcstring.h>
|
||||
#include <fennec/lang/strings/detail/_ctype.h>
|
||||
#include <fennec/lang/strings/wcstring.h>
|
||||
|
||||
#include <fennec/lang/assert.h>
|
||||
#include <fennec/langcpp/assert.h>
|
||||
|
||||
#include <fennec/memory/allocator.h>
|
||||
#include <fennec/memory/common.h>
|
||||
@@ -1,495 +0,0 @@
|
||||
// =====================================================================================================================
|
||||
// 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/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
///
|
||||
/// \file type_traits.h
|
||||
/// \brief \ref fennec_lang_type_traits
|
||||
///
|
||||
///
|
||||
/// \details
|
||||
/// \author Medusa Slockbower
|
||||
///
|
||||
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
|
||||
///
|
||||
///
|
||||
|
||||
#ifndef FENNEC_LANG_TYPE_TRAITS_H
|
||||
#define FENNEC_LANG_TYPE_TRAITS_H
|
||||
|
||||
///
|
||||
/// \page fennec_lang_type_traits Type Traits
|
||||
///
|
||||
/// \brief Part of the fennec metaprogramming library. This header defines structures for accessing traits of types
|
||||
/// at compile time.
|
||||
///
|
||||
/// \code #include <fennec/lang/type_traits.h> \endcode
|
||||
///
|
||||
///
|
||||
/// <table width="100%" class="fieldtable" id="table_fennec_lang_type_traits">
|
||||
/// <tr><th style="vertical-align: top">Syntax
|
||||
/// <th style="vertical-align: top">Description
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_void "is_void<TypeT>::value"<br>
|
||||
/// \ref fennec::is_void_v "is_void_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_void
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_bool "is_bool<TypeT>::value"<br>
|
||||
/// \ref fennec::is_bool_v "is_bool_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_bool
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_integral "is_integral<TypeT>::value"<br>
|
||||
/// \ref fennec::is_integral_v "is_integral_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_integral
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_signed "is_signed<TypeT>::value"<br>
|
||||
/// \ref fennec::is_signed_v "is_signed_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_signed
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_unsigned "is_unsigned<TypeT>::value"<br>
|
||||
/// \ref fennec::is_unsigned_v "is_unsigned_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_unsigned
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_floating_point "is_floating_point<TypeT>::value"<br>
|
||||
/// \ref fennec::is_floating_point_v "is_floating_point_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_floating_point
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_arithmetic "is_arithmetic<TypeT>::value"<br>
|
||||
/// \ref fennec::is_arithmetic_v "is_arithmetic_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_arithmetic
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_same "is_same<TypeT>::value"<br>
|
||||
/// \ref fennec::is_same_v "is_same_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_same
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_convertible "is_convertible<TypeT0, TypeT1>::value"<br>
|
||||
/// \ref fennec::is_convertible_v "is_convertible_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_convertible
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_constructible "is_constructible<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::is_constructible_v "is_constructible_v<ClassT, ArgsT...>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydoc fennec::is_constructible
|
||||
///
|
||||
/// </table>
|
||||
///
|
||||
|
||||
#include <fennec/lang/intrinsics.h>
|
||||
#include <fennec/lang/type_transforms.h>
|
||||
#include <fennec/lang/detail/_type_traits.h>
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
constexpr inline bool is_constant_evaluated() noexcept {
|
||||
if consteval {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// fennec::is_void =====================================================================================================
|
||||
|
||||
///
|
||||
/// \brief check if \p T is of type void
|
||||
///
|
||||
/// \details Stores a boolean value in `is_void::value`, representing whether the provided type is of base type void.
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_void
|
||||
: detail::_is_void<remove_cvr_t<T>>{};
|
||||
|
||||
///
|
||||
/// \brief shorthand for ```is_void<T>::value```
|
||||
/// \tparam T type to check
|
||||
template<typename T> constexpr bool_t is_void_v = is_void<T>::value;
|
||||
|
||||
|
||||
|
||||
// fennec::is_bool =====================================================================================================
|
||||
|
||||
///
|
||||
/// \brief check if \p T is of type bool
|
||||
///
|
||||
/// \details Stores a boolean value in `is_bool::value`, representing whether the provided type is of base type bool.
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_bool
|
||||
: detail::_is_bool<remove_cvr_t<T>>{};
|
||||
|
||||
///
|
||||
/// \brief shorthand for ```is_bool<T>::value```
|
||||
/// \tparam T type to check
|
||||
template<typename T> constexpr bool_t is_bool_v = is_bool<T>::value;
|
||||
|
||||
|
||||
|
||||
// fennec::is_null_pointer =============================================================================================
|
||||
|
||||
///
|
||||
/// \brief check if \p T is of type nullptr_t
|
||||
///
|
||||
/// \details Stores a boolean value in `is_null_pointer::value`, representing whether the provided type is of base type nullptr_t.
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_null_pointer
|
||||
: detail::_is_null_pointer<remove_cvr_t<T>>{};
|
||||
|
||||
///
|
||||
/// \brief shorthand for ```is_null_pointer<T>::value```
|
||||
/// \tparam T type to check
|
||||
template<typename T> constexpr bool_t is_null_pointer_v = is_null_pointer<T>::value;
|
||||
|
||||
|
||||
|
||||
// fennec::is_array ====================================================================================================
|
||||
|
||||
#ifdef FENNEC_BUILTIN_IS_ARRAY
|
||||
|
||||
///
|
||||
/// \brief check if \p T is of an array type
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_array
|
||||
: bool_constant<FENNEC_BUILTIN_IS_ARRAY(T)> {};
|
||||
|
||||
#else
|
||||
|
||||
///
|
||||
/// \brief check if \p T is of an array type
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_array
|
||||
: false_type {};
|
||||
|
||||
// overload for a sized array type
|
||||
template<typename T, size_t N> struct is_array<T[N]>
|
||||
: true_type {};
|
||||
|
||||
// overload for a generic array type
|
||||
template<typename T> struct is_array<T[]>
|
||||
: true_type {};
|
||||
|
||||
#endif
|
||||
|
||||
///
|
||||
/// \brief shorthand for ```is_array<T>::value```
|
||||
/// \tparam T type to check
|
||||
template<typename T> constexpr bool_t is_array_v = is_array<T>::value;
|
||||
|
||||
// fennec::is_class ====================================================================================================
|
||||
|
||||
///
|
||||
/// \brief check if \p T is a class
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_class
|
||||
: bool_constant<FENNEC_BUILTIN_IS_CLASS(T)> {};
|
||||
|
||||
///
|
||||
/// \brief check if \p T is a class
|
||||
/// \tparam T type to check
|
||||
template<typename T> constexpr size_t is_class_v = is_class<T>::value;
|
||||
|
||||
|
||||
|
||||
// Integral Types ======================================================================================================
|
||||
|
||||
///
|
||||
/// \brief check if \p T is of an integral
|
||||
///
|
||||
/// \details Stores a boolean value in `is_integral::value`, representing whether the provided type is of a base integer type.
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_integral
|
||||
: detail::_is_integral<remove_cvr_t<T>> {};
|
||||
|
||||
///
|
||||
/// \brief shorthand for ```is_integral<T>::value```
|
||||
/// \tparam T type to check
|
||||
template<typename T> constexpr bool_t is_integral_v = is_integral<T>::value;
|
||||
|
||||
|
||||
///
|
||||
/// \brief check if \p T is of a signed integral
|
||||
///
|
||||
/// \details Checks if type `T` is a signed type i.e. `T(-1) < T(0)` and stores it in `is_same::value`.
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_signed
|
||||
: detail::_is_signed<remove_cvr_t<T>> {};
|
||||
|
||||
///
|
||||
/// \brief shorthand for ```is_signed<T>::value```
|
||||
/// \tparam T type to check
|
||||
template<typename T> constexpr bool_t is_signed_v = is_signed<T>::value;
|
||||
|
||||
|
||||
///
|
||||
/// \brief check if \p T is of an unsigned integral
|
||||
///
|
||||
/// \details Checks if type `T` is an unsigned type i.e. `T(-1) > T(0)` and stores it in `is_same::value`.
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_unsigned
|
||||
: detail::_is_unsigned<remove_cvr_t<T>> {};
|
||||
|
||||
///
|
||||
/// \brief shorthand for ```is_unsigned<T>::value```
|
||||
/// \tparam T type to check
|
||||
template<typename T> constexpr bool_t is_unsigned_v = is_unsigned<T>::value;
|
||||
|
||||
|
||||
|
||||
// Floating Point Types ================================================================================================
|
||||
|
||||
///
|
||||
/// \brief check if \p T is of a floating point type
|
||||
///
|
||||
/// \details Checks if type `T` is a floating point type and store it in `is_same::value`.
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_floating_point
|
||||
: detail::_is_floating_point<remove_cvr_t<T>>{};
|
||||
|
||||
///
|
||||
/// \brief shorthand for ```is_floating_point<T>::value```
|
||||
/// \tparam T type to check
|
||||
template<typename T> constexpr bool_t is_floating_point_v = is_floating_point<T> {};
|
||||
|
||||
|
||||
// Pointer Types =======================================================================================================
|
||||
|
||||
///
|
||||
/// \brief check if \p T is of a floating point type
|
||||
///
|
||||
/// \details Checks if type `T` is a floating point type and store it in `is_same::value`.
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_pointer
|
||||
: detail::_is_pointer<remove_cvr_t<T>>{};
|
||||
|
||||
///
|
||||
/// \brief shorthand for ```is_floating_point<T>::value```
|
||||
/// \tparam T type to check
|
||||
template<typename T> constexpr bool_t is_pointer_v = is_pointer<T> {};
|
||||
|
||||
|
||||
|
||||
// Arithmetic Types ====================================================================================================
|
||||
|
||||
///
|
||||
/// \brief check if \p T is an arithmetic type
|
||||
///
|
||||
/// \details Checks if type `T` is a built-in type with arithmetic operators and store it in `is_same::value`.
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_arithmetic
|
||||
: bool_constant<is_integral_v<T> or is_floating_point_v<T>>{};
|
||||
|
||||
///
|
||||
/// \brief shorthand for ```is_arithmetic<T>::value```
|
||||
/// \tparam T type to check
|
||||
template<typename T> constexpr bool_t is_arithmetic_v = is_arithmetic<T>::value;
|
||||
|
||||
|
||||
// fennec::is_fundamental ==============================================================================================
|
||||
|
||||
///
|
||||
/// \brief check if \p T is a fundamental type, i.e. arithmetic, void, or nullptr_t
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_fundamental
|
||||
: bool_constant<is_arithmetic_v<T> || is_void_v<T> || is_null_pointer_v<T>>{};
|
||||
|
||||
///
|
||||
/// \brief shorthand for ```is_fundamental<T>::value```
|
||||
/// \tparam T type to check
|
||||
template<typename T> constexpr bool_t is_fundamental_v = is_fundamental<T>::value;
|
||||
|
||||
|
||||
// fennec::is_same =====================================================================================================
|
||||
|
||||
///
|
||||
/// \brief check if the two types are identical
|
||||
///
|
||||
/// \details Checks if `T0` and `T1` are identical and store it in `is_same::value`
|
||||
/// \tparam T0 first type to check
|
||||
/// \tparam T1 second type to check
|
||||
template<typename T0, typename T1> struct is_same : false_type {};
|
||||
|
||||
// true case
|
||||
template<typename T> struct is_same<T, T> : true_type {};
|
||||
|
||||
///
|
||||
/// \brief shorthand for ```is_same<T0, T1>::value```
|
||||
/// \tparam T type to check
|
||||
template<typename T0, typename T1> constexpr bool_t is_same_v = is_same<T0, T1> {};
|
||||
|
||||
// fennec::is_convertible ==============================================================================================
|
||||
|
||||
///
|
||||
/// \brief check if type `T0` can be converted `T1`
|
||||
///
|
||||
/// \details Checks if `TypeT0`
|
||||
/// \tparam FromT First type
|
||||
/// \tparam ToT Second type
|
||||
template<typename FromT, typename ToT> struct is_convertible
|
||||
: bool_constant<FENNEC_BUILTIN_IS_CONVERTIBLE(FromT, ToT)> {};
|
||||
|
||||
///
|
||||
/// \brief shorthand for `can_convert<TypeT0, TypeT1>::value`
|
||||
/// \param FromT First type
|
||||
/// \param ToT Second type
|
||||
template<typename FromT, typename ToT> constexpr bool_t is_convertible_v = is_convertible<FromT, ToT>{};
|
||||
|
||||
|
||||
// fennec::is_constructible ============================================================================================
|
||||
|
||||
///
|
||||
/// \brief Check if `ClassT` can be constructed with `ArgsT,` i.e. `ClassT(ArgsT...)`.
|
||||
/// This may be read as "is `ClassT` constructible with `ArgsT`"
|
||||
/// \tparam ClassT The class type to test
|
||||
/// \tparam ArgsT The arguments for the specific constructor
|
||||
template<typename ClassT, typename...ArgsT> struct is_constructible
|
||||
: bool_constant<FENNEC_BUILTIN_IS_CONSTRUCTIBLE(ClassT, ArgsT...)> {};
|
||||
|
||||
///
|
||||
/// \brief Shorthand for `is_constructible<ClassT, ArgsT...>::value`
|
||||
template<typename ClassT, typename...ArgsT> constexpr bool_t is_constructible_v = is_constructible<ClassT, ArgsT...>{};
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// \brief Check if `ClassT` is default constructible
|
||||
/// \tparam ClassT The class type to test
|
||||
template<typename ClassT> struct is_default_constructible
|
||||
: bool_constant<FENNEC_BUILTIN_IS_CONSTRUCTIBLE(ClassT,)> {};
|
||||
|
||||
///
|
||||
/// \brief Shorthand for `is_default_constructible<ClassT>::value`
|
||||
template<typename ClassT, typename...ArgsT> constexpr bool_t is_default_constructible_v = is_default_constructible<ClassT>{};
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// \brief Check if `ClassT` is copy constructible
|
||||
/// \tparam ClassT The class type to test
|
||||
template<typename ClassT> struct is_copy_constructible
|
||||
: bool_constant<FENNEC_BUILTIN_IS_CONSTRUCTIBLE(ClassT, add_lvalue_reference_t<const ClassT>)> {};
|
||||
|
||||
///
|
||||
/// \brief Shorthand for `is_copy_constructible<ClassT>::value`
|
||||
template<typename ClassT, typename...ArgsT> constexpr bool_t is_copy_constructible_v = is_copy_constructible<ClassT>{};
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// \brief Check if `ClassT` is copy constructible
|
||||
/// \tparam ClassT The class type to test
|
||||
template<typename ClassT> struct is_move_constructible
|
||||
: bool_constant<FENNEC_BUILTIN_IS_CONSTRUCTIBLE(ClassT, add_rvalue_reference_t<ClassT>)> {};
|
||||
|
||||
///
|
||||
/// \brief Shorthand for `is_copy_constructible<ClassT>::value`
|
||||
template<typename ClassT, typename...ArgsT> constexpr bool_t is_move_constructible_v = is_move_constructible<ClassT>{};
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// \brief Check if `ClassT` is trivially constructible
|
||||
/// \tparam ClassT The class type to test
|
||||
template<typename ClassT> struct is_trivially_constructible
|
||||
: bool_constant<FENNEC_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE(ClassT)> {};
|
||||
|
||||
///
|
||||
/// \brief Shorthand for `is_trivially_constructible<ClassT, ArgsT...>::value`
|
||||
template<typename ClassT> constexpr bool_t is_trivially_constructible_v = is_trivially_constructible<ClassT>{};
|
||||
|
||||
|
||||
// fennec::is_trivially_destructible ===================================================================================
|
||||
|
||||
///
|
||||
/// \brief Check if `ClassT` is trivially destructible
|
||||
/// \tparam ClassT The class type to test
|
||||
template<typename ClassT> struct is_trivially_destructible
|
||||
: bool_constant<FENNEC_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE(ClassT)> {};
|
||||
|
||||
///
|
||||
/// \brief Shorthand for `is_trivially_destructible<ClassT, ArgsT...>::value`
|
||||
template<typename ClassT> constexpr bool_t is_trivially_destructible_v = is_trivially_destructible<ClassT>{};
|
||||
|
||||
|
||||
// fennec::is_assignable ===============================================================================================
|
||||
|
||||
///
|
||||
/// \brief Check if `ClassT` can be constructed with `ArgsT,` i.e. `ClassT(ArgsT...)`.
|
||||
/// This may be read as "is `ClassT` constructible with `ArgsT`"
|
||||
/// \tparam ClassAT The class type to test
|
||||
/// \tparam ClassBT The arguments for the specific constructor
|
||||
template<typename ClassAT, typename ClassBT> struct is_assignable
|
||||
: bool_constant<FENNEC_BUILTIN_IS_ASSIGNABLE(ClassAT, ClassBT)> {};
|
||||
|
||||
///
|
||||
/// \brief Shorthand for `is_constructible<ClassT, ArgsT...>::value`
|
||||
template<typename ClassT, typename...ArgsT> constexpr bool_t is_assignable_v = is_assignable<ClassT, ArgsT...>{};
|
||||
|
||||
|
||||
// fennec::is_copy_assignable ==========================================================================================
|
||||
|
||||
///
|
||||
/// \brief Check if `ClassT` is copy assignable
|
||||
/// \tparam ClassT The class type to test
|
||||
template<typename ClassT> struct is_copy_assignable
|
||||
: bool_constant<FENNEC_BUILTIN_IS_ASSIGNABLE(add_lvalue_reference_t<ClassT>, add_lvalue_reference_t<const ClassT>)> {};
|
||||
|
||||
///
|
||||
/// \brief Shorthand for `is_copy_assignable<ClassT>::value`
|
||||
template<typename ClassT> constexpr bool_t is_copy_assignable_v = is_copy_assignable<ClassT>{};
|
||||
|
||||
|
||||
// fennec::is_move_assignable ==========================================================================================
|
||||
|
||||
///
|
||||
/// \brief Check if `ClassT` is move assignable
|
||||
/// \tparam ClassT The class type to test
|
||||
template<typename ClassT> struct is_move_assignable
|
||||
: bool_constant<FENNEC_BUILTIN_IS_ASSIGNABLE(add_lvalue_reference_t<ClassT>, add_rvalue_reference_t<ClassT>)> {};
|
||||
|
||||
///
|
||||
/// \brief Shorthand for `is_move_assignable<ClassT>::value`
|
||||
template<typename ClassT> constexpr bool_t is_move_assignable_v = is_move_assignable<ClassT>{};
|
||||
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_LANG_TYPE_TRAITS_H
|
||||
@@ -34,7 +34,7 @@
|
||||
///
|
||||
/// \page fennec_lang_assert Assertions
|
||||
///
|
||||
/// \code #include <fennec/lang/assert.h> \endcode
|
||||
/// \code #include <fennec/langcpp/assert.h> \endcode
|
||||
///
|
||||
/// This header contains macros for making assertions about code behaviour.
|
||||
///
|
||||
@@ -34,7 +34,7 @@
|
||||
///
|
||||
/// \page fennec_lang_bit_manipulation Bit Manipulation
|
||||
///
|
||||
/// \code #include <fennec/lang/bits.h> \endcode
|
||||
/// \code #include <fennec/langcpp/bits.h> \endcode
|
||||
///
|
||||
/// This header contains definitions for manipulating the bits of a provided object or pointer.
|
||||
///
|
||||
@@ -79,9 +79,9 @@
|
||||
///
|
||||
///
|
||||
|
||||
#include <fennec/lang/intrinsics.h>
|
||||
#include <fennec/langcpp/intrinsics.h>
|
||||
#include <fennec/memory/common.h>
|
||||
#include <fennec/lang/detail/_bits.h>
|
||||
#include <fennec/langcpp/detail/_bits.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
@@ -19,7 +19,7 @@
|
||||
#ifndef FENNEC_LANG_COMPARE_H
|
||||
#define FENNEC_LANG_COMPARE_H
|
||||
|
||||
#include <fennec/lang/type_operators.h>
|
||||
#include <fennec/langcpp/type_operators.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
@@ -32,12 +32,12 @@
|
||||
#ifndef FENNEC_LANG_CONDITIONAL_TYPES_H
|
||||
#define FENNEC_LANG_CONDITIONAL_TYPES_H
|
||||
|
||||
#include <fennec/lang/type_identity.h>
|
||||
#include <fennec/langcpp/type_identity.h>
|
||||
|
||||
///
|
||||
/// \page fennec_lang_conditional_types Conditional Types
|
||||
///
|
||||
/// \code #include <fennec/lang/conditional_types.h> \endcode
|
||||
/// \code #include <fennec/langcpp/conditional_types.h> \endcode
|
||||
///
|
||||
/// This header contains various compile-time functions for conditionally setting types, detecting types, or
|
||||
/// conditionally enabling functions. <br><br>
|
||||
@@ -36,7 +36,7 @@
|
||||
///
|
||||
/// \brief This header is part of the metaprogramming library. It defines structures for sequences of values, used during compile time.
|
||||
///
|
||||
/// \code #include <fennec/lang/sequences.h> \endcode
|
||||
/// \code #include <fennec/langcpp/sequences.h> \endcode
|
||||
///
|
||||
/// <table width="100%" class="fieldtable" id="table_fennec_lang_sequences">
|
||||
/// <tr><th style="vertical-align: top">Syntax
|
||||
@@ -70,7 +70,7 @@
|
||||
/// </table>
|
||||
///
|
||||
|
||||
#include <fennec/lang/type_traits.h>
|
||||
#include <fennec/langcpp/type_traits.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
@@ -31,7 +31,7 @@
|
||||
#ifndef FENNEC_LANG_CONSTANTS_H
|
||||
#define FENNEC_LANG_CONSTANTS_H
|
||||
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/langcpp/types.h>
|
||||
|
||||
///
|
||||
///
|
||||
@@ -40,7 +40,7 @@
|
||||
/// \brief This header is part of the metaprogramming library. It defines structures for constant values,
|
||||
/// used during compile time.
|
||||
///
|
||||
/// \code #include <fennec/lang/constants.h> \endcode
|
||||
/// \code #include <fennec/langcpp/constants.h> \endcode
|
||||
///
|
||||
/// <table width="100%" class="fieldtable" id="table_fennec_lang_constants">
|
||||
/// <tr><th style="vertical-align: top">Syntax
|
||||
@@ -19,7 +19,7 @@
|
||||
#ifndef FENNEC_LANG_DETAIL_BITS_H
|
||||
#define FENNEC_LANG_DETAIL_BITS_H
|
||||
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/langcpp/types.h>
|
||||
|
||||
namespace fennec::detail
|
||||
{
|
||||
@@ -19,8 +19,8 @@
|
||||
#ifndef FENNEC_LANG_DETAIL_NUMERIC_TRANSFORMS_H
|
||||
#define FENNEC_LANG_DETAIL_NUMERIC_TRANSFORMS_H
|
||||
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/lang/type_transforms.h>
|
||||
#include <fennec/langcpp/types.h>
|
||||
#include <fennec/langcpp/type_transforms.h>
|
||||
|
||||
namespace fennec::detail
|
||||
{
|
||||
@@ -19,7 +19,7 @@
|
||||
#ifndef FENNEC_LANG_DETAIL_TYPE_SEQUENCES_H
|
||||
#define FENNEC_LANG_DETAIL_TYPE_SEQUENCES_H
|
||||
|
||||
#include <fennec/lang/type_transforms.h>
|
||||
#include <fennec/langcpp/type_transforms.h>
|
||||
|
||||
namespace fennec::detail
|
||||
{
|
||||
@@ -19,8 +19,7 @@
|
||||
#ifndef FENNEC_LANG_DETAIL_TYPE_TRAITS_H
|
||||
#define FENNEC_LANG_DETAIL_TYPE_TRAITS_H
|
||||
|
||||
#include <fennec/lang/constants.h>
|
||||
#include <fennec/lang/float.h>
|
||||
#include <fennec/langcpp/constants.h>
|
||||
|
||||
namespace fennec::detail
|
||||
{
|
||||
@@ -70,6 +69,27 @@ namespace fennec::detail
|
||||
|
||||
template<typename T> struct _declval_protector : bool_constant<false> {};
|
||||
|
||||
template<typename T> struct _is_complete {
|
||||
template<typename U>
|
||||
static auto test(U*) -> bool_constant<sizeof(U) == sizeof(U)>;
|
||||
static auto test(...) -> false_type;
|
||||
using type = decltype(_is_complete::test(static_cast<T*>(nullptr)));
|
||||
};
|
||||
|
||||
template<typename T> struct _is_destructible {
|
||||
template<typename U, typename = decltype(_declval<T&>().~T())>
|
||||
static auto test(int) -> true_type;
|
||||
static auto test(...) -> false_type;
|
||||
using type = decltype(test<T>(0));
|
||||
};
|
||||
|
||||
template<typename T> struct _is_nothrow_destructible {
|
||||
template<typename U, typename = decltype(noexcept(_declval<T&>().~T()))>
|
||||
static auto test(int) -> true_type;
|
||||
static auto test(...) -> false_type;
|
||||
using type = decltype(test<T>(0));
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_LANG_DETAIL_TYPE_TRAITS_H
|
||||
@@ -19,7 +19,7 @@
|
||||
#ifndef FENNEC_LANG_DETAIL_TYPE_TRANSFORMS_H
|
||||
#define FENNEC_LANG_DETAIL_TYPE_TRANSFORMS_H
|
||||
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/langcpp/types.h>
|
||||
|
||||
namespace fennec::detail
|
||||
{
|
||||
@@ -30,7 +30,7 @@
|
||||
#ifndef FENNEC_LANG_FLOAT_H
|
||||
#define FENNEC_LANG_FLOAT_H
|
||||
|
||||
#include <fennec/lang/bits.h>
|
||||
#include <fennec/langcpp/bits.h>
|
||||
|
||||
#undef FLT_HAS_INFINITY
|
||||
#undef FLT_HAS_QUIET_NAN
|
||||
@@ -19,8 +19,8 @@
|
||||
#ifndef FENNEC_LANG_HASHING_H
|
||||
#define FENNEC_LANG_HASHING_H
|
||||
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/lang/type_traits.h>
|
||||
#include <fennec/langcpp/types.h>
|
||||
#include <fennec/langcpp/type_traits.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
@@ -33,7 +33,7 @@
|
||||
/// \brief This header contains definitions for compiler intrinsics necessary for implementing functions of the
|
||||
/// C++ stdlib.
|
||||
///
|
||||
/// \code{.cpp}#include <fennec/lang/intrinsics.h>\endcode
|
||||
/// \code{.cpp}#include <fennec/langcpp/intrinsics.h>\endcode
|
||||
///
|
||||
///
|
||||
/// <table width="100%" class="fieldtable" id="table_fennec_lang_intrinsics">
|
||||
@@ -17,7 +17,7 @@
|
||||
// =====================================================================================================================
|
||||
|
||||
///
|
||||
/// \file lang.h
|
||||
/// \file langcpp.h
|
||||
/// \brief \ref fennec_lang
|
||||
///
|
||||
///
|
||||
@@ -31,10 +31,10 @@
|
||||
#ifndef FENNEC_LANG_H
|
||||
#define FENNEC_LANG_H
|
||||
|
||||
#include <fennec/lang/assert.h>
|
||||
#include <fennec/lang/bits.h>
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/lang/utility.h>
|
||||
#include <fennec/langcpp/assert.h>
|
||||
#include <fennec/langcpp/bits.h>
|
||||
#include <fennec/langcpp/types.h>
|
||||
#include <fennec/langcpp/utility.h>
|
||||
|
||||
///
|
||||
/// \page fennec_lang C++ Language Library
|
||||
@@ -39,7 +39,7 @@
|
||||
/// floats and integers. There are overloads for all builtin types, and overloads for other types are included in
|
||||
/// their own header.
|
||||
///
|
||||
/// \code{.cpp}#include <fennec/lang/limits.h>\endcode
|
||||
/// \code{.cpp}#include <fennec/langcpp/limits.h>\endcode
|
||||
///
|
||||
/// \section fennec_lang_limits_numeric_limits Numeric Limits
|
||||
/// <table width="100%" class="fieldtable" id="table_fennec_lang_limits">
|
||||
@@ -197,11 +197,11 @@
|
||||
///
|
||||
///
|
||||
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/lang/type_traits.h>
|
||||
#include <fennec/langcpp/types.h>
|
||||
#include <fennec/langcpp/type_traits.h>
|
||||
|
||||
#include <fennec/lang/integer.h>
|
||||
#include <fennec/lang/float.h>
|
||||
#include <fennec/langcpp/integer.h>
|
||||
#include <fennec/langcpp/float.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
@@ -33,7 +33,7 @@
|
||||
///
|
||||
/// \page fennec_lang_numeric_transforms Numeric Transforms
|
||||
///
|
||||
/// \code #include <fennec/lang/numeric_transforms.h> \endcode
|
||||
/// \code #include <fennec/langcpp/numeric_transforms.h> \endcode
|
||||
///
|
||||
/// This header contains various compile-time functions for changing the characteristics of a provided type
|
||||
///
|
||||
@@ -54,8 +54,8 @@
|
||||
///
|
||||
/// </table>
|
||||
|
||||
#include <fennec/lang/type_transforms.h>
|
||||
#include <fennec/lang/detail/_numeric_transforms.h>
|
||||
#include <fennec/langcpp/type_transforms.h>
|
||||
#include <fennec/langcpp/detail/_numeric_transforms.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
@@ -25,7 +25,7 @@
|
||||
/// \brief Part of the fennec metaprogramming library. This header defines structures for copying types with different traits
|
||||
/// or rather, transform them, at compile time.
|
||||
///
|
||||
/// \code #include <fennec/lang/type_identity.h> \endcode
|
||||
/// \code #include <fennec/langcpp/type_identity.h> \endcode
|
||||
///
|
||||
///
|
||||
/// <table width="100%" class="fieldtable" id="table_fennec_lang_type_identity">
|
||||
@@ -36,7 +36,7 @@
|
||||
///
|
||||
/// \brief This header is part of the metaprogramming library. It defines structures for sequences of types, used during compile time.
|
||||
///
|
||||
/// \code #include <fennec/lang/type_sequences.h> \endcode
|
||||
/// \code #include <fennec/langcpp/type_sequences.h> \endcode
|
||||
///
|
||||
/// <table width="100%" class="fieldtable" id="table_fennec_lang_type_sequences">
|
||||
/// <tr><th style="vertical-align: top">Syntax
|
||||
@@ -54,7 +54,7 @@
|
||||
/// </table>
|
||||
///
|
||||
|
||||
#include <fennec/lang/detail/_type_sequences.h>
|
||||
#include <fennec/langcpp/detail/_type_sequences.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
854
include/fennec/langcpp/type_traits.h
Normal file
854
include/fennec/langcpp/type_traits.h
Normal file
@@ -0,0 +1,854 @@
|
||||
// =====================================================================================================================
|
||||
// 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/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
///
|
||||
/// \file type_traits.h
|
||||
/// \brief \ref fennec_lang_type_traits
|
||||
///
|
||||
///
|
||||
/// \details
|
||||
/// \author Medusa Slockbower
|
||||
///
|
||||
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
|
||||
///
|
||||
///
|
||||
|
||||
#ifndef FENNEC_LANG_TYPE_TRAITS_H
|
||||
#define FENNEC_LANG_TYPE_TRAITS_H
|
||||
|
||||
///
|
||||
/// \page fennec_lang_type_traits Type Traits
|
||||
///
|
||||
/// \brief Part of the fennec metaprogramming library. This header defines structures for accessing traits of types
|
||||
/// at compile time.
|
||||
///
|
||||
/// \code #include <fennec/langcpp/type_traits.h> \endcode
|
||||
///
|
||||
///
|
||||
///
|
||||
/// \section Primary Type Categories
|
||||
///
|
||||
/// <table width="100%" class="fieldtable" id="table_fennec_lang_type_traits_primary_categories">
|
||||
/// <tr><th style="vertical-align: top">Syntax
|
||||
/// <th style="vertical-align: top">Description
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_void "is_void<TypeT>::value"<br>
|
||||
/// \ref fennec::is_void_v "is_void_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_void
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_null_pointer "is_null_pointer<TypeT>::value"<br>
|
||||
/// \ref fennec::is_null_pointer_v "is_null_pointer_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_null_pointer
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_bool "is_bool<TypeT>::value"<br>
|
||||
/// \ref fennec::is_bool_v "is_bool_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_bool
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_integral "is_integral<TypeT>::value"<br>
|
||||
/// \ref fennec::is_integral_v "is_integral_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_integral
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_floating_point "is_floating_point<TypeT>::value"<br>
|
||||
/// \ref fennec::is_floating_point_v "is_floating_point_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_floating_point
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_array "is_array<TypeT>::value"<br>
|
||||
/// \ref fennec::is_array_v "is_array_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_array
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_enum "is_enum<TypeT>::value"<br>
|
||||
/// \ref fennec::is_enum_v "is_enum_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_enum
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_union "is_union<TypeT>::value"<br>
|
||||
/// \ref fennec::is_union_v "is_union_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_union
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_class "is_class<TypeT>::value"<br>
|
||||
/// \ref fennec::is_class_v "is_class_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_class
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_function "is_function<TypeT>::value"<br>
|
||||
/// \ref fennec::is_function_v "is_function_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_function
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_pointer "is_pointer<TypeT>::value"<br>
|
||||
/// \ref fennec::is_pointer_v "is_pointer_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_pointer
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_lvalue_reference "is_lvalue_reference<TypeT>::value"<br>
|
||||
/// \ref fennec::is_lvalue_reference_v "is_lvalue_reference_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_lvalue_reference
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_rvalue_reference "is_rvalue_reference<TypeT>::value"<br>
|
||||
/// \ref fennec::is_rvalue_reference_v "is_rvalue_reference_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_rvalue_reference
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_member_object_pointer "is_member_object_pointer<TypeT>::value"<br>
|
||||
/// \ref fennec::is_member_object_pointer_v "is_member_object_pointer_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_member_object_pointer
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_member_function_pointer "is_member_function_pointer<TypeT>::value"<br>
|
||||
/// \ref fennec::is_member_function_pointer_v "is_member_function_pointer_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_member_function_pointer
|
||||
///
|
||||
/// </table>
|
||||
///
|
||||
///
|
||||
///
|
||||
/// \section Composite Type Categories
|
||||
///
|
||||
/// <table width="100%" class="fieldtable" id="table_fennec_lang_type_traits_composite_categories">
|
||||
/// <tr><th style="vertical-align: top">Syntax
|
||||
/// <th style="vertical-align: top">Description
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_fundamental "is_fundamental<TypeT>::value"<br>
|
||||
/// \ref fennec::is_fundamental_v "is_fundamental_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_fundamental
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_arithmetic "is_arithmetic<TypeT>::value"<br>
|
||||
/// \ref fennec::is_arithmetic_v "is_arithmetic_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_arithmetic
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_scalar "is_scalar<TypeT>::value"<br>
|
||||
/// \ref fennec::is_scalar_v "is_scalar_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_scalar
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_object "is_object<TypeT>::value"<br>
|
||||
/// \ref fennec::is_object_v "is_object_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_object
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_compound "is_compound<TypeT>::value"<br>
|
||||
/// \ref fennec::is_compound_v "is_compound_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_compound
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_reference "is_reference<TypeT>::value"<br>
|
||||
/// \ref fennec::is_reference_v "is_reference_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_reference
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_member_pointer "is_member_pointer<TypeT>::value"<br>
|
||||
/// \ref fennec::is_member_pointer_v "is_member_pointer_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_member_pointer
|
||||
///
|
||||
/// </table>
|
||||
///
|
||||
///
|
||||
///
|
||||
/// \section Type Properties
|
||||
///
|
||||
/// <table width="100%" class="fieldtable" id="table_fennec_lang_type_traits_type_properties">
|
||||
/// <tr><th style="vertical-align: top">Syntax
|
||||
/// <th style="vertical-align: top">Description
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_const "is_const<TypeT>::value"<br>
|
||||
/// \ref fennec::is_const_v "is_const_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_const
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_volatile "is_volatile<TypeT>::value"<br>
|
||||
/// \ref fennec::is_volatile_v "is_volatile_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_volatile
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_trivial "is_trivial<TypeT>::value"<br>
|
||||
/// \ref fennec::is_trivial_v "is_trivial_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_trivial
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_trivially_copyable "is_trivially_copyable<TypeT>::value"<br>
|
||||
/// \ref fennec::is_trivially_copyable_v "is_trivially_copyable_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_trivially_copyable
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_standard_layout "is_standard_layout<TypeT>::value"<br>
|
||||
/// \ref fennec::is_standard_layout_v "is_standard_layout_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_standard_layout
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::has_unique_object_representations "has_unique_object_representations<TypeT>::value"<br>
|
||||
/// \ref fennec::has_unique_object_representations_v "has_unique_object_representations_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::has_unique_object_representations
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_empty "is_empty<TypeT>::value"<br>
|
||||
/// \ref fennec::is_empty_v "is_empty_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_empty
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_polymorphic "is_polymorphic<TypeT>::value"<br>
|
||||
/// \ref fennec::is_polymorphic_v "is_polymorphic_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_polymorphic
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_abstract "is_abstract<TypeT>::value"<br>
|
||||
/// \ref fennec::is_abstract_v "is_abstract_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_abstract
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_complete "is_complete<TypeT>::value"<br>
|
||||
/// \ref fennec::is_complete_v "is_complete_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_complete
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_final "is_final<TypeT>::value"<br>
|
||||
/// \ref fennec::is_final_v "is_final_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_final
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_aggregate "is_aggregate<TypeT>::value"<br>
|
||||
/// \ref fennec::is_aggregate_v "is_aggregate_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_aggregate
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_implicit_lifetime "is_implicit_lifetime<TypeT>::value"<br>
|
||||
/// \ref fennec::is_implicit_lifetime_v "is_implicit_lifetime_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_implicit_lifetime
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_signed "is_signed<TypeT>::value"<br>
|
||||
/// \ref fennec::is_signed_v "is_signed_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_signed
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_unsigned "is_unsigned<TypeT>::value"<br>
|
||||
/// \ref fennec::is_unsigned_v "is_unsigned_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_unsigned
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_bounded_array "is_bounded_array<TypeT>::value"<br>
|
||||
/// \ref fennec::is_bounded_array_v "is_bounded_array_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_bounded_array
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_unbounded_array "is_unbounded_array<TypeT>::value"<br>
|
||||
/// \ref fennec::is_unbounded_array_v "is_unbounded_array_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_unbounded_array
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_scoped_enum "is_scoped_enum<TypeT>::value"<br>
|
||||
/// \ref fennec::is_scoped_enum_v "is_scoped_enum_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_scoped_enum
|
||||
///
|
||||
/// </table>
|
||||
///
|
||||
///
|
||||
///
|
||||
/// \section Supported Operations
|
||||
///
|
||||
/// <table width="100%" class="fieldtable" id="table_fennec_lang_type_traits_supported_operations">
|
||||
/// <tr><th style="vertical-align: top">Syntax
|
||||
/// <th style="vertical-align: top">Description
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_convertible "is_convertible<TypeT0, TypeT1>::value"<br>
|
||||
/// \ref fennec::is_convertible_v "is_convertible_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_convertible
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_constructible "is_constructible<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::is_constructible_v "is_constructible_v<ClassT, ArgsT...>"
|
||||
/// \ref fennec::is_trivially_constructible "is_trivially_constructible<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::is_trivially_constructible_v "is_trivially_constructible_v<ClassT, ArgsT...>"
|
||||
/// \ref fennec::is_nothrow_constructible "is_nothrow_constructible<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::is_nothrow_constructible_v "is_nothrow_constructible_v<ClassT, ArgsT...>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_constructible
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_default_constructible "is_default_constructible<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::is_default_constructible_v "is_default_constructible_v<ClassT, ArgsT...>"
|
||||
/// \ref fennec::is_trivially_default_constructible "is_trivially_default_constructible<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::is_trivially_default_constructible_v "is_trivially_default_constructible_v<ClassT, ArgsT...>"
|
||||
/// \ref fennec::is_nothrow_default_constructible "is_nothrow_default_constructible<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::is_nothrow_default_constructible_v "is_nothrow_default_constructible_v<ClassT, ArgsT...>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_default_constructible
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_copy_constructible "is_copy_constructible<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::is_copy_constructible_v "is_copy_constructible_v<ClassT, ArgsT...>"
|
||||
/// \ref fennec::is_trivially_copy_constructible "is_trivially_copy_constructible<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::is_trivially_copy_constructible_v "is_trivially_copy_constructible_v<ClassT, ArgsT...>"
|
||||
/// \ref fennec::is_nothrow_copy_constructible "is_nothrow_copy_constructible<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::is_nothrow_copy_constructible_v "is_nothrow_copy_constructible_v<ClassT, ArgsT...>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_copy_constructible
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_move_constructible "is_move_constructible<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::is_move_constructible_v "is_move_constructible_v<ClassT, ArgsT...>"
|
||||
/// \ref fennec::is_trivially_move_constructible "is_trivially_move_constructible<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::is_trivially_move_constructible_v "is_trivially_move_constructible_v<ClassT, ArgsT...>"
|
||||
/// \ref fennec::is_nothrow_move_constructible "is_nothrow_move_constructible<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::is_nothrow_move_constructible_v "is_nothrow_move_constructible_v<ClassT, ArgsT...>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \movedetails fennec::is_move_constructible
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_assignable "is_assignable<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::is_assignable_v "is_assignable_v<ClassT, ArgsT...>"
|
||||
/// \ref fennec::is_trivially_assignable "is_trivially_assignable<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::is_trivially_assignable_v "is_trivially_assignable_v<ClassT, ArgsT...>"
|
||||
/// \ref fennec::is_nothrow_assignable "is_nothrow_assignable<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::is_nothrow_assignable_v "is_nothrow_assignable_v<ClassT, ArgsT...>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_assignable
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_copy_assignable "is_copy_assignable<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::is_copy_assignable_v "is_copy_assignable_v<ClassT, ArgsT...>"
|
||||
/// \ref fennec::is_trivially_copy_assignable "is_trivially_copy_assignable<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::is_trivially_copy_assignable_v "is_trivially_copy_assignable_v<ClassT, ArgsT...>"
|
||||
/// \ref fennec::is_nothrow_copy_assignable "is_nothrow_copy_assignable<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::is_nothrow_copy_assignable_v "is_nothrow_copy_assignable_v<ClassT, ArgsT...>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_copy_assignable
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_move_assignable "is_move_assignable<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::is_move_assignable_v "is_move_assignable_v<ClassT, ArgsT...>"
|
||||
/// \ref fennec::is_trivially_move_assignable "is_trivially_move_assignable<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::is_trivially_move_assignable_v "is_trivially_move_assignable_v<ClassT, ArgsT...>"
|
||||
/// \ref fennec::is_nothrow_move_assignable "is_nothrow_move_assignable<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::is_nothrow_move_assignable_v "is_nothrow_move_assignable_v<ClassT, ArgsT...>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \movedetails fennec::is_move_assignable
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_destructible "is_destructible<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::is_destructible_v "is_destructible_v<ClassT, ArgsT...>"
|
||||
/// \ref fennec::is_trivially_destructible "is_trivially_destructible<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::is_trivially_destructible_v "is_trivially_destructible_v<ClassT, ArgsT...>"
|
||||
/// \ref fennec::is_nothrow_destructible "is_nothrow_destructible<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::is_nothrow_destructible_v "is_nothrow_destructible_v<ClassT, ArgsT...>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_destructible
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::has_virtual_destructor "has_virtual_destructor<ClassT, ArgsT...>::value"<br>
|
||||
/// \ref fennec::has_virtual_destructor_v "has_virtual_destructor_v<ClassT, ArgsT...>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::has_virtual_destructor
|
||||
///
|
||||
/// </table>
|
||||
///
|
||||
///
|
||||
///
|
||||
/// \section Type Relationships
|
||||
///
|
||||
/// <table width="100%" class="fieldtable" id="table_fennec_lang_type_traits_type_relationships">
|
||||
/// <tr><th style="vertical-align: top">Syntax
|
||||
/// <th style="vertical-align: top">Description
|
||||
///
|
||||
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
||||
/// \ref fennec::is_same "is_same<TypeT>::value"<br>
|
||||
/// \ref fennec::is_same_v "is_same_v<TypeT>"
|
||||
/// <td width="50%" style="vertical-align: top">
|
||||
/// \copydetails fennec::is_same
|
||||
///
|
||||
/// </table>
|
||||
///
|
||||
|
||||
#include <fennec/langcpp/intrinsics.h>
|
||||
#include <fennec/langcpp/type_transforms.h>
|
||||
#include <fennec/langcpp/detail/_type_traits.h>
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
constexpr inline bool is_constant_evaluated() noexcept {
|
||||
if consteval {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// fennec::is_void =====================================================================================================
|
||||
|
||||
///
|
||||
/// \brief check if \p T is of type void
|
||||
///
|
||||
/// \details Stores a boolean value in `is_void::value`, representing whether the provided type is of base type void.
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_void
|
||||
: detail::_is_void<remove_cvr_t<T>>{};
|
||||
|
||||
///
|
||||
/// \brief shorthand for ```is_void<T>::value```
|
||||
/// \tparam T type to check
|
||||
template<typename T> constexpr bool_t is_void_v = is_void<T>::value;
|
||||
|
||||
|
||||
|
||||
// fennec::is_null_pointer =============================================================================================
|
||||
|
||||
///
|
||||
/// \brief check if \p T is of type nullptr_t
|
||||
///
|
||||
/// \details Stores a boolean value in `is_null_pointer::value`, representing whether the provided type is of base type nullptr_t.
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_null_pointer
|
||||
: detail::_is_null_pointer<remove_cvr_t<T>>{};
|
||||
|
||||
///
|
||||
/// \brief shorthand for ```is_null_pointer<T>::value```
|
||||
/// \tparam T type to check
|
||||
template<typename T> constexpr bool_t is_null_pointer_v = is_null_pointer<T>::value;
|
||||
|
||||
|
||||
|
||||
// fennec::is_array ====================================================================================================
|
||||
|
||||
#ifdef FENNEC_BUILTIN_IS_ARRAY
|
||||
|
||||
///
|
||||
/// \brief check if \p T is of an array type
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_array
|
||||
: bool_constant<FENNEC_BUILTIN_IS_ARRAY(T)> {};
|
||||
|
||||
#else
|
||||
|
||||
///
|
||||
/// \brief check if \p T is of an array type
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_array
|
||||
: false_type {};
|
||||
|
||||
// overload for a sized array type
|
||||
template<typename T, size_t N> struct is_array<T[N]>
|
||||
: true_type {};
|
||||
|
||||
// overload for a generic array type
|
||||
template<typename T> struct is_array<T[]>
|
||||
: true_type {};
|
||||
|
||||
#endif
|
||||
|
||||
///
|
||||
/// \brief shorthand for ```is_array<T>::value```
|
||||
/// \tparam T type to check
|
||||
template<typename T> constexpr bool_t is_array_v = is_array<T>::value;
|
||||
|
||||
// fennec::is_class ====================================================================================================
|
||||
|
||||
///
|
||||
/// \brief check if \p T is a class
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_class
|
||||
: bool_constant<FENNEC_BUILTIN_IS_CLASS(T)> {};
|
||||
|
||||
///
|
||||
/// \brief check if \p T is a class
|
||||
/// \tparam T type to check
|
||||
template<typename T> constexpr size_t is_class_v = is_class<T>::value;
|
||||
|
||||
|
||||
|
||||
// Integral Types ======================================================================================================
|
||||
|
||||
|
||||
|
||||
// fennec::is_bool =====================================================================================================
|
||||
|
||||
///
|
||||
/// \brief check if \p T is of type bool
|
||||
///
|
||||
/// \details Stores a boolean value in `is_bool::value`, representing whether the provided type is of base type bool.
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_bool
|
||||
: detail::_is_bool<remove_cvr_t<T>>{};
|
||||
|
||||
///
|
||||
/// \brief shorthand for ```is_bool<T>::value```
|
||||
/// \tparam T type to check
|
||||
template<typename T> constexpr bool_t is_bool_v = is_bool<T>::value;
|
||||
|
||||
///
|
||||
/// \brief check if \p T is of an integral
|
||||
///
|
||||
/// \details Stores a boolean value in `is_integral::value`, representing whether the provided type is of a base integer type.
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_integral
|
||||
: detail::_is_integral<remove_cvr_t<T>> {};
|
||||
|
||||
///
|
||||
/// \brief shorthand for ```is_integral<T>::value```
|
||||
/// \tparam T type to check
|
||||
template<typename T> constexpr bool_t is_integral_v = is_integral<T>::value;
|
||||
|
||||
|
||||
///
|
||||
/// \brief check if \p T is of a signed integral
|
||||
///
|
||||
/// \details Checks if type `T` is a signed type i.e. `T(-1) < T(0)` and stores it in `is_same::value`.
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_signed
|
||||
: detail::_is_signed<remove_cvr_t<T>> {};
|
||||
|
||||
///
|
||||
/// \brief shorthand for ```is_signed<T>::value```
|
||||
/// \tparam T type to check
|
||||
template<typename T> constexpr bool_t is_signed_v = is_signed<T>::value;
|
||||
|
||||
|
||||
///
|
||||
/// \brief check if \p T is of an unsigned integral
|
||||
///
|
||||
/// \details Checks if type `T` is an unsigned type i.e. `T(-1) > T(0)` and stores it in `is_same::value`.
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_unsigned
|
||||
: detail::_is_unsigned<remove_cvr_t<T>> {};
|
||||
|
||||
///
|
||||
/// \brief shorthand for ```is_unsigned<T>::value```
|
||||
/// \tparam T type to check
|
||||
template<typename T> constexpr bool_t is_unsigned_v = is_unsigned<T>::value;
|
||||
|
||||
|
||||
|
||||
// Floating Point Types ================================================================================================
|
||||
|
||||
///
|
||||
/// \brief check if \p T is of a floating point type
|
||||
///
|
||||
/// \details Checks if type `T` is a floating point type and store it in `is_same::value`.
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_floating_point
|
||||
: detail::_is_floating_point<remove_cvr_t<T>>{};
|
||||
|
||||
///
|
||||
/// \brief shorthand for ```is_floating_point<T>::value```
|
||||
/// \tparam T type to check
|
||||
template<typename T> constexpr bool_t is_floating_point_v = is_floating_point<T> {};
|
||||
|
||||
|
||||
// Pointer Types =======================================================================================================
|
||||
|
||||
///
|
||||
/// \brief check if \p T is of a floating point type
|
||||
///
|
||||
/// \details Checks if type `T` is a floating point type and store it in `is_same::value`.
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_pointer
|
||||
: detail::_is_pointer<remove_cvr_t<T>>{};
|
||||
|
||||
///
|
||||
/// \brief shorthand for ```is_floating_point<T>::value```
|
||||
/// \tparam T type to check
|
||||
template<typename T> constexpr bool_t is_pointer_v = is_pointer<T> {};
|
||||
|
||||
|
||||
|
||||
// Arithmetic Types ====================================================================================================
|
||||
|
||||
///
|
||||
/// \brief check if \p T is an arithmetic type
|
||||
///
|
||||
/// \details Checks if type `T` is a built-in type with arithmetic operators and store it in `is_same::value`.
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_arithmetic
|
||||
: bool_constant<is_integral_v<T> or is_floating_point_v<T>>{};
|
||||
|
||||
///
|
||||
/// \brief shorthand for ```is_arithmetic<T>::value```
|
||||
/// \tparam T type to check
|
||||
template<typename T> constexpr bool_t is_arithmetic_v = is_arithmetic<T>::value;
|
||||
|
||||
|
||||
// fennec::is_fundamental ==============================================================================================
|
||||
|
||||
///
|
||||
/// \brief check if \p T is a fundamental type, i.e. arithmetic, void, or nullptr_t
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_fundamental
|
||||
: bool_constant<is_arithmetic_v<T> || is_void_v<T> || is_null_pointer_v<T>>{};
|
||||
|
||||
///
|
||||
/// \brief shorthand for ```is_fundamental<T>::value```
|
||||
/// \tparam T type to check
|
||||
template<typename T> constexpr bool_t is_fundamental_v = is_fundamental<T>::value;
|
||||
|
||||
|
||||
// fennec::is_same =====================================================================================================
|
||||
|
||||
///
|
||||
/// \brief check if the two types are identical
|
||||
///
|
||||
/// \details Checks if `T0` and `T1` are identical and store it in `is_same::value`
|
||||
/// \tparam T0 first type to check
|
||||
/// \tparam T1 second type to check
|
||||
template<typename T0, typename T1> struct is_same : false_type {};
|
||||
|
||||
// true case
|
||||
template<typename T> struct is_same<T, T> : true_type {};
|
||||
|
||||
///
|
||||
/// \brief shorthand for ```is_same<T0, T1>::value```
|
||||
/// \tparam T0 first type to check
|
||||
/// \tparam T1 second type to check
|
||||
template<typename T0, typename T1> constexpr bool_t is_same_v = is_same<T0, T1> {};
|
||||
|
||||
// fennec::is_complete ==============================================================================================
|
||||
|
||||
///
|
||||
/// \brief check if type `T` is complete
|
||||
///
|
||||
/// \details Checks if `T`
|
||||
/// \tparam T type to check
|
||||
template<typename T> struct is_complete : detail::_is_complete<T>::type {};
|
||||
|
||||
///
|
||||
/// \brief shorthand for `is_complete<TypeT0, TypeT1>::value`
|
||||
/// \tparam T type to check
|
||||
template<typename T> constexpr bool_t is_complete_v = is_complete<T>{};
|
||||
|
||||
// fennec::is_convertible ==============================================================================================
|
||||
|
||||
///
|
||||
/// \brief check if type `T0` can be converted `T1`
|
||||
///
|
||||
/// \details Checks if `TypeT0`
|
||||
/// \tparam FromT First type
|
||||
/// \tparam ToT Second type
|
||||
template<typename FromT, typename ToT> struct is_convertible
|
||||
: bool_constant<FENNEC_BUILTIN_IS_CONVERTIBLE(FromT, ToT)> {};
|
||||
|
||||
///
|
||||
/// \brief shorthand for `can_convert<TypeT0, TypeT1>::value`
|
||||
/// \param FromT First type
|
||||
/// \param ToT Second type
|
||||
template<typename FromT, typename ToT> constexpr bool_t is_convertible_v = is_convertible<FromT, ToT>{};
|
||||
|
||||
|
||||
// fennec::is_constructible ============================================================================================
|
||||
|
||||
///
|
||||
/// \brief Check if `ClassT` can be constructed with `ArgsT,` i.e. `ClassT(ArgsT...)`.
|
||||
/// This may be read as "is `ClassT` constructible with `ArgsT`"
|
||||
/// \tparam ClassT The class type to test
|
||||
/// \tparam ArgsT The arguments for the specific constructor
|
||||
template<typename ClassT, typename...ArgsT> struct is_constructible
|
||||
: bool_constant<FENNEC_BUILTIN_IS_CONSTRUCTIBLE(ClassT, ArgsT...)> {};
|
||||
|
||||
///
|
||||
/// \brief Shorthand for `is_constructible<ClassT, ArgsT...>::value`
|
||||
template<typename ClassT, typename...ArgsT> constexpr bool_t is_constructible_v = is_constructible<ClassT, ArgsT...>{};
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// \brief Check if `ClassT` is trivially constructible
|
||||
/// \tparam ClassT The class type to test
|
||||
template<typename ClassT> struct is_trivially_constructible
|
||||
: bool_constant<FENNEC_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE(ClassT)> {};
|
||||
|
||||
///
|
||||
/// \brief Shorthand for `is_trivially_constructible<ClassT, ArgsT...>::value`
|
||||
template<typename ClassT> constexpr bool_t is_trivially_constructible_v = is_trivially_constructible<ClassT>{};
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// \brief Check if `ClassT` is default constructible
|
||||
/// \tparam ClassT The class type to test
|
||||
template<typename ClassT> struct is_default_constructible
|
||||
: bool_constant<FENNEC_BUILTIN_IS_CONSTRUCTIBLE(ClassT,)> {};
|
||||
|
||||
///
|
||||
/// \brief Shorthand for `is_default_constructible<ClassT>::value`
|
||||
template<typename ClassT, typename...ArgsT> constexpr bool_t is_default_constructible_v = is_default_constructible<ClassT>{};
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// \brief Check if `ClassT` is copy constructible
|
||||
/// \tparam ClassT The class type to test
|
||||
template<typename ClassT> struct is_copy_constructible
|
||||
: bool_constant<FENNEC_BUILTIN_IS_CONSTRUCTIBLE(ClassT, add_lvalue_reference_t<const ClassT>)> {};
|
||||
|
||||
///
|
||||
/// \brief Shorthand for `is_copy_constructible<ClassT>::value`
|
||||
template<typename ClassT, typename...ArgsT> constexpr bool_t is_copy_constructible_v = is_copy_constructible<ClassT>{};
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// \brief Check if `ClassT` is copy constructible
|
||||
/// \tparam ClassT The class type to test
|
||||
template<typename ClassT> struct is_move_constructible
|
||||
: bool_constant<FENNEC_BUILTIN_IS_CONSTRUCTIBLE(ClassT, add_rvalue_reference_t<ClassT>)> {};
|
||||
|
||||
///
|
||||
/// \brief Shorthand for `is_copy_constructible<ClassT>::value`
|
||||
template<typename ClassT, typename...ArgsT> constexpr bool_t is_move_constructible_v = is_move_constructible<ClassT>{};
|
||||
|
||||
|
||||
// fennec::is_destructible ===================================================================================
|
||||
|
||||
///
|
||||
/// \brief Check if `ClassT` is destructible
|
||||
/// \tparam ClassT The class type to test
|
||||
template<typename ClassT> struct is_destructible
|
||||
: detail::_is_destructible<ClassT>::type {};
|
||||
|
||||
///
|
||||
/// \brief Shorthand for `is_destructible<ClassT, ArgsT...>::value`
|
||||
template<typename ClassT> constexpr bool_t is_destructible_v = is_destructible<ClassT>{};
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// \brief Check if `ClassT` is trivially destructible
|
||||
/// \tparam ClassT The class type to test
|
||||
template<typename ClassT> struct is_trivially_destructible
|
||||
: bool_constant<FENNEC_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE(ClassT)> {};
|
||||
|
||||
///
|
||||
/// \brief Shorthand for `is_trivially_destructible<ClassT, ArgsT...>::value`
|
||||
template<typename ClassT> constexpr bool_t is_trivially_destructible_v = is_trivially_destructible<ClassT>{};
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// \brief Check if `ClassT` is nothrow destructible
|
||||
/// \tparam ClassT The class type to test
|
||||
template<typename ClassT> struct is_nothrow_destructible
|
||||
: detail::_is_nothrow_destructible<ClassT>::type {};
|
||||
|
||||
///
|
||||
/// \brief Shorthand for `is_nothrow_destructible<ClassT, ArgsT...>::value`
|
||||
template<typename ClassT> constexpr bool_t is_nothrow_destructible_v = is_nothrow_destructible<ClassT>{};
|
||||
|
||||
|
||||
// fennec::is_assignable ===============================================================================================
|
||||
|
||||
///
|
||||
/// \brief Check if `ClassT` can be constructed with `ArgsT,` i.e. `ClassT(ArgsT...)`.
|
||||
/// This may be read as "is `ClassT` constructible with `ArgsT`"
|
||||
/// \tparam ClassAT The class type to test
|
||||
/// \tparam ClassBT The arguments for the specific constructor
|
||||
template<typename ClassAT, typename ClassBT> struct is_assignable
|
||||
: bool_constant<FENNEC_BUILTIN_IS_ASSIGNABLE(ClassAT, ClassBT)> {};
|
||||
|
||||
///
|
||||
/// \brief Shorthand for `is_constructible<ClassT, ArgsT...>::value`
|
||||
template<typename ClassT, typename...ArgsT> constexpr bool_t is_assignable_v = is_assignable<ClassT, ArgsT...>{};
|
||||
|
||||
|
||||
// fennec::is_copy_assignable ==========================================================================================
|
||||
|
||||
///
|
||||
/// \brief Check if `ClassT` is copy assignable
|
||||
/// \tparam ClassT The class type to test
|
||||
template<typename ClassT> struct is_copy_assignable
|
||||
: bool_constant<FENNEC_BUILTIN_IS_ASSIGNABLE(add_lvalue_reference_t<ClassT>, add_lvalue_reference_t<const ClassT>)> {};
|
||||
|
||||
///
|
||||
/// \brief Shorthand for `is_copy_assignable<ClassT>::value`
|
||||
template<typename ClassT> constexpr bool_t is_copy_assignable_v = is_copy_assignable<ClassT>{};
|
||||
|
||||
|
||||
// fennec::is_move_assignable ==========================================================================================
|
||||
|
||||
///
|
||||
/// \brief Check if `ClassT` is move assignable
|
||||
/// \tparam ClassT The class type to test
|
||||
template<typename ClassT> struct is_move_assignable
|
||||
: bool_constant<FENNEC_BUILTIN_IS_ASSIGNABLE(add_lvalue_reference_t<ClassT>, add_rvalue_reference_t<ClassT>)> {};
|
||||
|
||||
///
|
||||
/// \brief Shorthand for `is_move_assignable<ClassT>::value`
|
||||
template<typename ClassT> constexpr bool_t is_move_assignable_v = is_move_assignable<ClassT>{};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_LANG_TYPE_TRAITS_H
|
||||
@@ -31,8 +31,9 @@
|
||||
#ifndef FENNEC_LANG_TYPE_TRANSFORMS_H
|
||||
#define FENNEC_LANG_TYPE_TRANSFORMS_H
|
||||
|
||||
#include <fennec/lang/type_identity.h>
|
||||
#include <fennec/lang/detail/_type_transforms.h>
|
||||
#include <fennec/langcpp/type_identity.h>
|
||||
#include <fennec/langcpp/detail/_type_traits.h>
|
||||
#include <fennec/langcpp/detail/_type_transforms.h>
|
||||
|
||||
///
|
||||
/// \page fennec_lang_type_transforms Type Transforms
|
||||
@@ -40,7 +41,7 @@
|
||||
/// \brief Part of the fennec metaprogramming library. This header defines structures for copying types with different traits
|
||||
/// or rather, transform them, at compile time.
|
||||
///
|
||||
/// \code #include <fennec/lang/type_transforms.h> \endcode
|
||||
/// \code #include <fennec/langcpp/type_transforms.h> \endcode
|
||||
///
|
||||
///
|
||||
/// <table width="100%" class="fieldtable" id="table_fennec_lang_type_transforms">
|
||||
@@ -154,6 +155,20 @@ template<typename T> struct remove_pointer<T*> : type_identity<T> {};
|
||||
template<typename T> using remove_pointer_t = typename remove_pointer<T>::type;
|
||||
|
||||
|
||||
///
|
||||
/// \brief removes all pointer levels from \p T
|
||||
///
|
||||
/// \details removes all pointers from the provided type such that `T*`, `T**`, etc. becomes `T`
|
||||
/// \tparam T Resultant Type
|
||||
template<typename T> struct strip_pointers : conditional_t<
|
||||
detail::_is_pointer<T>::value,
|
||||
strip_pointers<remove_pointer_t<T>>,
|
||||
type_identity<T>
|
||||
> {};
|
||||
|
||||
template<typename T> using strip_pointers_t = strip_pointers<T>::type;
|
||||
|
||||
|
||||
|
||||
// Reference Conversions ===============================================================================================
|
||||
|
||||
@@ -347,6 +362,20 @@ template<typename T> struct remove_cvr : type_identity<remove_cv_t<remove_refere
|
||||
/// \brief shorthand for `typename remove_cvr<T>::type`
|
||||
template<typename T> using remove_cvr_t = typename remove_cvr<T>::type;
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// \brief removes references and pointers as well as the const and volatile qualifiers from the provided type \p T
|
||||
///
|
||||
/// \details removes const and volatile from the provided type such that
|
||||
/// \tparam T Reference Type
|
||||
template<typename T> struct remove_cvrp : type_identity<remove_cv_t<remove_reference_t<strip_pointers_t<T>>>> {};
|
||||
|
||||
|
||||
///
|
||||
/// \brief shorthand for `typename remove_cvrp_t<T>::type`
|
||||
template<typename T> using remove_cvrp_t = typename remove_cvrp<T>::type;
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_LANG_TYPE_TRANSFORMS_H
|
||||
@@ -34,7 +34,7 @@
|
||||
///
|
||||
/// \page fennec_lang_types Types
|
||||
///
|
||||
/// \code #include <fennec/lang/types.h> \endcode
|
||||
/// \code #include <fennec/langcpp/types.h> \endcode
|
||||
///
|
||||
/// \brief This header contains definitions for the built-in types of the C++ language.
|
||||
///
|
||||
@@ -201,9 +201,9 @@
|
||||
///
|
||||
///
|
||||
|
||||
#include <fennec/lang/detail/_int.h>
|
||||
#include <fennec/langcpp/detail/_int.h>
|
||||
|
||||
#include <fennec/lang/conditional_types.h>
|
||||
#include <fennec/langcpp/conditional_types.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
@@ -36,7 +36,7 @@
|
||||
///
|
||||
/// \brief This header contains common utility functions related to the C++ language.
|
||||
///
|
||||
/// \code #include <fennec/lang/utility.h> \endcode
|
||||
/// \code #include <fennec/langcpp/utility.h> \endcode
|
||||
///
|
||||
/// <table width="100%" class="fieldtable" id="table_fennec_lang_utility">
|
||||
/// <tr><th style="vertical-align: top">Syntax
|
||||
@@ -59,8 +59,8 @@
|
||||
/// </table>
|
||||
///
|
||||
|
||||
#include <fennec/lang/type_transforms.h>
|
||||
#include <fennec/lang/type_traits.h>
|
||||
#include <fennec/langcpp/type_transforms.h>
|
||||
#include <fennec/langcpp/type_traits.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
@@ -123,9 +123,19 @@ constexpr void swap(T& x, T& y) noexcept {
|
||||
/// \param x first value
|
||||
/// \param y second value
|
||||
template<typename T> constexpr void swap(T& x, T& y) noexcept {
|
||||
|
||||
#if FENNEC_COMPILER_GCC
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
||||
#endif
|
||||
|
||||
T a = fennec::move(x);
|
||||
x = fennec::move(y);
|
||||
y = fennec::move(a);
|
||||
|
||||
#if FENNEC_COMPILER_GCC
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
@@ -271,7 +271,7 @@
|
||||
|
||||
#include <fennec/math/detail/_math.h>
|
||||
|
||||
#include <fennec/lang/limits.h>
|
||||
#include <fennec/langcpp/limits.h>
|
||||
|
||||
#include <fennec/math/vector.h>
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#ifndef FENNEC_MATH_DETAIL_TYPES_H
|
||||
#define FENNEC_MATH_DETAIL_TYPES_H
|
||||
|
||||
#include <fennec/lang/const_sequences.h>
|
||||
#include <fennec/langcpp/const_sequences.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
#include <fennec/math/detail/_fwd.h>
|
||||
|
||||
#include <fennec/lang/type_traits.h>
|
||||
#include <fennec/langcpp/type_traits.h>
|
||||
#include <fennec/math/swizzle.h>
|
||||
|
||||
namespace fennec
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#ifndef FENNEC_MATH_EXT_COMMON_H
|
||||
#define FENNEC_MATH_EXT_COMMON_H
|
||||
|
||||
#include <fennec/lang/limits.h>
|
||||
#include <fennec/langcpp/limits.h>
|
||||
|
||||
#include <fennec/math/trigonometric.h>
|
||||
#include <fennec/math/ext/quaternion.h>
|
||||
|
||||
@@ -111,7 +111,7 @@
|
||||
///
|
||||
///
|
||||
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/langcpp/types.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
///
|
||||
///
|
||||
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/langcpp/types.h>
|
||||
|
||||
#include <fennec/math/detail/_fwd.h>
|
||||
#include <fennec/math/detail/_types.h>
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
///
|
||||
///
|
||||
|
||||
#include <fennec/lang/const_sequences.h>
|
||||
#include <fennec/langcpp/const_sequences.h>
|
||||
|
||||
#include <fennec/math/swizzle_storage.h>
|
||||
|
||||
|
||||
@@ -108,9 +108,9 @@
|
||||
#include <fennec/math/vector_base.h>
|
||||
#include <fennec/math/vector_traits.h>
|
||||
|
||||
#include <fennec/lang/conditional_types.h>
|
||||
#include <fennec/lang/type_traits.h>
|
||||
#include <fennec/lang/utility.h>
|
||||
#include <fennec/langcpp/conditional_types.h>
|
||||
#include <fennec/langcpp/type_traits.h>
|
||||
#include <fennec/langcpp/utility.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
@@ -35,10 +35,10 @@
|
||||
#include <fennec/memory/pointer_traits.h>
|
||||
#include <fennec/memory/new.h>
|
||||
|
||||
#include <fennec/lang/conditional_types.h>
|
||||
#include <fennec/lang/numeric_transforms.h>
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/lang/type_traits.h>
|
||||
#include <fennec/langcpp/conditional_types.h>
|
||||
#include <fennec/langcpp/numeric_transforms.h>
|
||||
#include <fennec/langcpp/types.h>
|
||||
#include <fennec/langcpp/type_traits.h>
|
||||
|
||||
#include <fennec/math/ext/constants.h>
|
||||
#include <fennec/math/common.h>
|
||||
@@ -366,7 +366,8 @@ public:
|
||||
constexpr allocation(size_t n, const alloc_t& alloc) noexcept
|
||||
: _alloc(alloc)
|
||||
, _data(nullptr)
|
||||
, _capacity(0) {
|
||||
, _capacity(0)
|
||||
, _alignment(zero<align_t>()) {
|
||||
callocate(n);
|
||||
}
|
||||
|
||||
@@ -450,7 +451,7 @@ public:
|
||||
/// \param alloc the allocation to copy
|
||||
/// \returns a reference to `this`
|
||||
constexpr allocation& operator=(const allocation& alloc) {
|
||||
allocation::allocate(alloc.capacity());
|
||||
allocation::allocate(alloc.capacity(), alloc.alignment());
|
||||
fennec::memmove(_data, alloc, size());
|
||||
return *this;
|
||||
}
|
||||
@@ -465,12 +466,13 @@ public:
|
||||
fennec::swap(_alloc, alloc._alloc);
|
||||
fennec::swap(_data, alloc._data);
|
||||
fennec::swap(_capacity, alloc._capacity);
|
||||
fennec::swap(_alignment, alloc._alignment);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// Allocation and Deallocation =====================================================================================
|
||||
// Allocation and Deallocation =========================================================================================
|
||||
|
||||
///
|
||||
/// \brief Allocate a block of memory for the allocation.
|
||||
@@ -627,6 +629,10 @@ public:
|
||||
return _data;
|
||||
}
|
||||
|
||||
constexpr align_t alignment() const {
|
||||
return _alignment;
|
||||
}
|
||||
|
||||
protected:
|
||||
alloc_t _alloc; // Allocator object
|
||||
value_t* _data; // Handle for the memory block
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
#ifndef FENNEC_LANG_BYTES_H
|
||||
#define FENNEC_LANG_BYTES_H
|
||||
|
||||
#include <fennec/lang/assert.h>
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/lang/hashing.h>
|
||||
#include <fennec/langcpp/assert.h>
|
||||
#include <fennec/langcpp/types.h>
|
||||
#include <fennec/langcpp/hashing.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#ifndef FENNEC_MEMORY_H
|
||||
#define FENNEC_MEMORY_H
|
||||
|
||||
#include <fennec/lang/type_traits.h>
|
||||
#include <fennec/langcpp/type_traits.h>
|
||||
#include <fennec/memory/detail/_string.h>
|
||||
|
||||
namespace fennec
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
#ifndef FENNEC_MEMORY_DETAIL_PTR_TRAITS_H
|
||||
#define FENNEC_MEMORY_DETAIL_PTR_TRAITS_H
|
||||
|
||||
#include <fennec/lang/conditional_types.h>
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/lang/type_traits.h>
|
||||
#include <fennec/lang/type_sequences.h>
|
||||
#include <fennec/langcpp/conditional_types.h>
|
||||
#include <fennec/langcpp/types.h>
|
||||
#include <fennec/langcpp/type_traits.h>
|
||||
#include <fennec/langcpp/type_sequences.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
#ifndef FENNEC_MEMORY_NEW_H
|
||||
#define FENNEC_MEMORY_NEW_H
|
||||
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/lang/utility.h>
|
||||
#include <fennec/langcpp/types.h>
|
||||
#include <fennec/langcpp/utility.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#ifndef FENNEC_MEMORY_PTR_TRAITS_H
|
||||
#define FENNEC_MEMORY_PTR_TRAITS_H
|
||||
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/langcpp/types.h>
|
||||
#include <fennec/memory/detail/_ptr_traits.h>
|
||||
|
||||
namespace fennec
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#ifndef FENNEC_MEMORY_POINTERS_H
|
||||
#define FENNEC_MEMORY_POINTERS_H
|
||||
|
||||
#include <fennec/lang/type_traits.h>
|
||||
#include <fennec/langcpp/type_traits.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
@@ -45,7 +45,7 @@ struct default_delete
|
||||
/// \param ptr Memory resource to delete
|
||||
constexpr void operator()(TypeT* ptr) const noexcept {
|
||||
static_assert(not is_void_v<TypeT>, "cannot delete a pointer to an incomplete type");
|
||||
static_assert(not sizeof(TypeT) > 0, "cannot delete a pointer to an incomplete type");
|
||||
static_assert(is_complete_v<TypeT>, "cannot delete a pointer to an incomplete type");
|
||||
delete ptr;
|
||||
}
|
||||
};
|
||||
@@ -70,7 +70,7 @@ struct default_delete<TypeT[]>
|
||||
template<class ArrT> requires requires { is_convertible_v<ArrT(*)[], TypeT(*)[]> == true; }
|
||||
constexpr void operator()(TypeT* ptr) const noexcept {
|
||||
static_assert(not is_void_v<TypeT>, "cannot delete a pointer to an incomplete type");
|
||||
static_assert(not sizeof(TypeT) > 0, "cannot delete a pointer to an incomplete type");
|
||||
static_assert(is_complete_v<TypeT>, "cannot delete a pointer to an incomplete type");
|
||||
delete[] ptr;
|
||||
}
|
||||
};
|
||||
@@ -91,6 +91,9 @@ public:
|
||||
/// \brief pointer to element type
|
||||
using pointer_t = element_t*;
|
||||
|
||||
/// \brief pointer to element type
|
||||
using const_pointer_t = const element_t*;
|
||||
|
||||
/// \brief the deleter
|
||||
using delete_t = DeleteT;
|
||||
|
||||
@@ -100,7 +103,7 @@ public:
|
||||
|
||||
///
|
||||
/// \brief Nullptr Constructor, creates a unique_ptr that owns nothing.
|
||||
constexpr unique_ptr(nullptr_t) noexcept : unique_ptr(nullptr) {}
|
||||
constexpr unique_ptr(nullptr_t) noexcept : unique_ptr(nullptr, delete_t()) {}
|
||||
|
||||
///
|
||||
/// \brief Pointer Constructor, creates a unique_ptr that owns `ptr` with deleter `del`
|
||||
@@ -115,7 +118,7 @@ public:
|
||||
/// \brief Pointer Constructor, creates a unique_ptr that owns `ptr` with deleter `del`
|
||||
/// \param ptr The resource to own
|
||||
/// \param del The deleter
|
||||
explicit constexpr unique_ptr(pointer_t ptr, delete_t&& del)
|
||||
explicit constexpr unique_ptr(pointer_t ptr, delete_t&& del = delete_t())
|
||||
: _delete(del)
|
||||
, _handle(ptr) {
|
||||
}
|
||||
@@ -152,12 +155,39 @@ public:
|
||||
return retval;
|
||||
}
|
||||
|
||||
pointer_t get() {
|
||||
return _handle;
|
||||
}
|
||||
|
||||
bool empty() {
|
||||
return _handle == nullptr;
|
||||
}
|
||||
|
||||
pointer_t operator->() {
|
||||
return _handle;
|
||||
}
|
||||
|
||||
const_pointer_t operator->() const {
|
||||
return _handle;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
delete_t _delete;
|
||||
pointer_t _handle;
|
||||
};
|
||||
|
||||
///
|
||||
/// \brief Creates a unique pointer holding an object of type `TypeT`
|
||||
/// \tparam TypeT The type
|
||||
/// \tparam ArgsT The constructor arguments, automatically deduced
|
||||
/// \param args The constructor arguments
|
||||
/// \returns A unique pointer holding a heap allocated object of type `TypeT` constructed with arguments `args`
|
||||
template<typename TypeT, typename...ArgsT>
|
||||
unique_ptr<TypeT> make_unique(ArgsT&&...args) {
|
||||
return unique_ptr<TypeT>(new TypeT(fennec::forward<ArgsT>(args)...));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_MEMORY_POINTERS_H
|
||||
|
||||
@@ -21,9 +21,8 @@
|
||||
|
||||
#include <fennec/containers/list.h>
|
||||
#include <fennec/containers/sequence.h>
|
||||
#include <fennec/langproc/strings/cstring.h>
|
||||
#include <fennec/langproc/strings/string.h>
|
||||
#include <fennec/lang/typed.h>
|
||||
#include <fennec/lang/strings/cstring.h>
|
||||
#include <fennec/lang/strings/string.h>
|
||||
#include <fennec/platform/interface/fwd.h>
|
||||
#include <fennec/platform/interface/window.h>
|
||||
|
||||
@@ -61,7 +60,7 @@
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class platform : public typed<platform> {
|
||||
class platform {
|
||||
public:
|
||||
using shared_object = struct shared_object;
|
||||
using symbol = void*;
|
||||
@@ -131,9 +130,8 @@ public:
|
||||
|
||||
protected:
|
||||
template<typename PlatformT>
|
||||
explicit platform(const cstring& name, PlatformT* type)
|
||||
: typed(type)
|
||||
, name(name) {
|
||||
explicit platform(const cstring& name, PlatformT*)
|
||||
: name(name) {
|
||||
assertf(globals.singleton == nullptr, "Conflicting platform implementations!");
|
||||
globals.singleton = this;
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
#ifndef FENNEC_PLATFORM_INTERFACE_WINDOW_H
|
||||
#define FENNEC_PLATFORM_INTERFACE_WINDOW_H
|
||||
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/langproc/strings/string.h>
|
||||
#include <fennec/langcpp/types.h>
|
||||
#include <fennec/lang/strings/string.h>
|
||||
#include <fennec/renderers/interface/gfxcontext.h>
|
||||
|
||||
namespace fennec
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
#ifndef FENNEC_RENDERERS_INTERFACE_GFXCONTEXT_H
|
||||
#define FENNEC_RENDERERS_INTERFACE_GFXCONTEXT_H
|
||||
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/langproc/strings/string.h>
|
||||
#include <fennec/langcpp/types.h>
|
||||
#include <fennec/lang/strings/string.h>
|
||||
#include <fennec/renderers/interface/forward.h>
|
||||
#include <fennec/renderers/interface/gfxresourcepool.h>
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
#ifndef FENNEC_PLATFORM_INTERFACE_GFXCONTEXT_H
|
||||
#define FENNEC_PLATFORM_INTERFACE_GFXCONTEXT_H
|
||||
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/langproc/strings/string.h>
|
||||
#include <fennec/langcpp/types.h>
|
||||
#include <fennec/lang/strings/string.h>
|
||||
#include <fennec/renderers/interface/forward.h>
|
||||
|
||||
namespace fennec
|
||||
|
||||
33
include/fennec/rtti/detail/_constants.h
Normal file
33
include/fennec/rtti/detail/_constants.h
Normal file
@@ -0,0 +1,33 @@
|
||||
// =====================================================================================================================
|
||||
// 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_RTTI_DETAIL_CONSTANTS_H
|
||||
#define FENNEC_RTTI_DETAIL_CONSTANTS_H
|
||||
|
||||
#include <fennec/langcpp/types.h>
|
||||
|
||||
namespace fennec::detail
|
||||
{
|
||||
|
||||
// const char* fennec::detail::f() [with T = void]
|
||||
inline static constexpr size_t type_name_f_heading = 42;
|
||||
inline static constexpr size_t type_name_f_footing = 1;
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_RTTI_DETAIL_CONSTANTS_H
|
||||
53
include/fennec/rtti/detail/_type_name.h
Normal file
53
include/fennec/rtti/detail/_type_name.h
Normal file
@@ -0,0 +1,53 @@
|
||||
// =====================================================================================================================
|
||||
// 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/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
///
|
||||
/// \file _type_name.h
|
||||
/// \brief
|
||||
///
|
||||
///
|
||||
/// \details
|
||||
/// \author Medusa Slockbower
|
||||
///
|
||||
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
|
||||
///
|
||||
///
|
||||
|
||||
#ifndef FENNEC_RTTI_DETAIL_TYPE_NAME_H
|
||||
#define FENNEC_RTTI_DETAIL_TYPE_NAME_H
|
||||
|
||||
#include <fennec/lang/strings/string.h>
|
||||
#include <fennec/rtti/detail/_constants.h>
|
||||
|
||||
namespace fennec::detail
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
inline static const char* f() {
|
||||
static constexpr const char* name = FENNEC_FUNCTION_NAME;
|
||||
return name + type_name_f_heading;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline static string_view type_name() {
|
||||
return string_view(f<T>(), ::strlen(f<T>()) - type_name_f_footing);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_RTTI_DETAIL_TYPE_NAME_H
|
||||
@@ -19,7 +19,7 @@
|
||||
#ifndef FENNEC_LANG_DETAIL_TYPEUUID_H
|
||||
#define FENNEC_LANG_DETAIL_TYPEUUID_H
|
||||
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/langcpp/types.h>
|
||||
|
||||
namespace fennec::detail
|
||||
{
|
||||
42
include/fennec/rtti/enable.h
Normal file
42
include/fennec/rtti/enable.h
Normal file
@@ -0,0 +1,42 @@
|
||||
// =====================================================================================================================
|
||||
// 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/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
///
|
||||
/// \file enable.h
|
||||
/// \brief
|
||||
///
|
||||
///
|
||||
/// \details
|
||||
/// \author Medusa Slockbower
|
||||
///
|
||||
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
|
||||
///
|
||||
///
|
||||
|
||||
#ifndef FENNEC_RTTI_ENABLE_H
|
||||
#define FENNEC_RTTI_ENABLE_H
|
||||
|
||||
#include <fennec/rtti/type.h>
|
||||
#include <fennec/rtti/typelist.h>
|
||||
|
||||
#define FENNEC_RTTI_ENABLE(...) \
|
||||
public: \
|
||||
using super_class_list = fennec::typelist<__VA_ARGS__>; \
|
||||
virtual fennec::type get_type() { return fennec::type::get_from_instance(this); }
|
||||
|
||||
#endif // FENNEC_RTTI_ENABLE_H
|
||||
34
include/fennec/rtti/forward.h
Normal file
34
include/fennec/rtti/forward.h
Normal file
@@ -0,0 +1,34 @@
|
||||
// =====================================================================================================================
|
||||
// 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/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
///
|
||||
/// \file forward.h
|
||||
/// \brief
|
||||
///
|
||||
///
|
||||
/// \details
|
||||
/// \author Medusa Slockbower
|
||||
///
|
||||
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
|
||||
///
|
||||
///
|
||||
|
||||
#ifndef FENNEC_RTTI_FORWARD_H
|
||||
#define FENNEC_RTTI_FORWARD_H
|
||||
|
||||
#endif // FENNEC_RTTI_FORWARD_H
|
||||
86
include/fennec/rtti/type.h
Normal file
86
include/fennec/rtti/type.h
Normal file
@@ -0,0 +1,86 @@
|
||||
// =====================================================================================================================
|
||||
// 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/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
///
|
||||
/// \file type.h
|
||||
/// \brief
|
||||
///
|
||||
///
|
||||
/// \details
|
||||
/// \author Medusa Slockbower
|
||||
///
|
||||
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
|
||||
///
|
||||
///
|
||||
|
||||
#ifndef FENNEC_RTTI_TYPE_H
|
||||
#define FENNEC_RTTI_TYPE_H
|
||||
|
||||
#include <fennec/langcpp/types.h>
|
||||
#include <fennec/rtti/type_data.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
struct type {
|
||||
|
||||
const string& name() const {
|
||||
return _data->name;
|
||||
}
|
||||
|
||||
uint64_t id() const {
|
||||
return _data->uuid;
|
||||
}
|
||||
|
||||
dynarray<type> supertypes() const {
|
||||
return _data->supers;
|
||||
}
|
||||
|
||||
dynarray<type> subtypes() const {
|
||||
return _data->subs;
|
||||
}
|
||||
|
||||
bool operator==(const type& c) const {
|
||||
return _data == c._data;
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Get the type info of the specified type
|
||||
/// \tparam TypeT The type to check
|
||||
/// \returns A type struct containing information about TypeT
|
||||
template<typename TypeT>
|
||||
static type get() { return type(static_cast<TypeT*>(nullptr)); }
|
||||
|
||||
template<typename TypeT>
|
||||
static type get_from_instance(TypeT* t) { return type(t); }
|
||||
|
||||
private:
|
||||
const type_data* const _data;
|
||||
|
||||
template<typename TypeT>
|
||||
type(TypeT*) : _data(type_storage::get_data<TypeT>()) {
|
||||
}
|
||||
|
||||
public:
|
||||
type(type_data* d) : _data(d) { }
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_RTTI_TYPE_H
|
||||
111
include/fennec/rtti/type_data.h
Normal file
111
include/fennec/rtti/type_data.h
Normal file
@@ -0,0 +1,111 @@
|
||||
// =====================================================================================================================
|
||||
// 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/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
///
|
||||
/// \file type_data.h
|
||||
/// \brief
|
||||
///
|
||||
///
|
||||
/// \details
|
||||
/// \author Medusa Slockbower
|
||||
///
|
||||
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
|
||||
///
|
||||
///
|
||||
|
||||
#ifndef FENNEC_RTTI_TYPE_DATA_H
|
||||
#define FENNEC_RTTI_TYPE_DATA_H
|
||||
|
||||
#include <fennec/containers/dynarray.h>
|
||||
#include <fennec/containers/optional.h>
|
||||
#include <fennec/lang/strings/string.h>
|
||||
#include <fennec/memory/pointers.h>
|
||||
#include <fennec/rtti/typeid.h>
|
||||
#include <fennec/rtti/typelist.h>
|
||||
#include <fennec/rtti/detail/_type_name.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
struct type_data {
|
||||
uint64_t uuid;
|
||||
string name;
|
||||
|
||||
type_data* raw_type;
|
||||
dynarray<type_data*> supers;
|
||||
dynarray<type_data*> subs;
|
||||
};
|
||||
|
||||
struct type_storage {
|
||||
private:
|
||||
template<typename ClassT> using _super_class_list = typename ClassT::super_class_list;
|
||||
|
||||
static dynarray<unique_ptr<type_data>>& _typelist() {
|
||||
static dynarray<unique_ptr<type_data>> typelist;
|
||||
return typelist;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static unique_ptr<type_data> _make_data() {
|
||||
using raw_t = remove_cvrp_t<T>;
|
||||
using supers_t = detect_t<typelist<>, _super_class_list, T>;
|
||||
|
||||
auto res = fennec::unique_ptr<type_data>(new type_data{
|
||||
.uuid = typeuuid<T>(),
|
||||
.name = detail::type_name<T>(),
|
||||
|
||||
.raw_type = typeuuid<raw_t>() == typeuuid<T>() ? nullptr : type_storage::get_data<raw_t>(),
|
||||
.supers = type_storage::get_data(supers_t{}),
|
||||
.subs = {}
|
||||
});
|
||||
|
||||
for (type_data* t : res->supers) {
|
||||
t->subs.push_back(res.get());
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public:
|
||||
template<typename T>
|
||||
static type_data* get_data() {
|
||||
auto& typelist = _typelist();
|
||||
uint64_t uuid = typeuuid<T>();
|
||||
|
||||
if (typelist.size() <= uuid) {
|
||||
typelist.resize(uuid * 2);
|
||||
}
|
||||
|
||||
if (typelist[uuid].empty()) {
|
||||
typelist[uuid] = fennec::forward<unique_ptr<type_data>>(_make_data<T>());
|
||||
}
|
||||
|
||||
return typelist[uuid].get();
|
||||
}
|
||||
|
||||
template<typename...Ts>
|
||||
static dynarray<type_data*> get_data(typelist<Ts...>) {
|
||||
return {
|
||||
get_data<Ts>()...
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_RTTI_TYPE_DATA_H
|
||||
@@ -19,11 +19,8 @@
|
||||
#ifndef FENNEC_LANG_TYPEUUID_H
|
||||
#define FENNEC_LANG_TYPEUUID_H
|
||||
|
||||
#include <fennec/lang/assert.h>
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/lang/type_traits.h>
|
||||
|
||||
#include <fennec/lang/detail/_typeuuid.h>
|
||||
#include <fennec/langcpp/types.h>
|
||||
#include <fennec/rtti/detail/_typeid.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
@@ -40,27 +37,6 @@ FENNEC_NO_INLINE uint64_t typeuuid() {
|
||||
return id = detail::_typeuuid<RootT>();
|
||||
}
|
||||
|
||||
template<typename RootT = void>
|
||||
struct typed {
|
||||
public:
|
||||
const uint64_t type;
|
||||
|
||||
template<typename TypeT>
|
||||
bool is_type() const {
|
||||
return type == typeuuid<TypeT, RootT>();
|
||||
}
|
||||
|
||||
template<typename TypeT>
|
||||
typed(TypeT*)
|
||||
: type(typeuuid<TypeT, RootT>()) {
|
||||
}
|
||||
|
||||
template<typename TypeT>
|
||||
static uint64_t id() {
|
||||
return typeuuid<TypeT, RootT>();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_LANG_TYPEUUID_H
|
||||
46
include/fennec/rtti/typelist.h
Normal file
46
include/fennec/rtti/typelist.h
Normal file
@@ -0,0 +1,46 @@
|
||||
// =====================================================================================================================
|
||||
// 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/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
///
|
||||
/// \file typelist.h
|
||||
/// \brief
|
||||
///
|
||||
///
|
||||
/// \details
|
||||
/// \author Medusa Slockbower
|
||||
///
|
||||
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
|
||||
///
|
||||
///
|
||||
|
||||
#ifndef FENNEC_RTTI_TYPELIST_H
|
||||
#define FENNEC_RTTI_TYPELIST_H
|
||||
|
||||
#include <fennec/langcpp/types.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
template<typename...TypesT>
|
||||
struct typelist {
|
||||
static constexpr size_t size = sizeof...(TypesT);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_RTTI_TYPELIST_H
|
||||
@@ -23,10 +23,11 @@
|
||||
#include <fennec/containers/map.h>
|
||||
#include <fennec/containers/optional.h>
|
||||
#include <fennec/containers/rdtree.h>
|
||||
#include <fennec/lang/startup.h>
|
||||
#include <fennec/langproc/strings/string.h>
|
||||
#include <fennec/lang/typed.h>
|
||||
#include <fennec/langproc/filesystem/path.h>
|
||||
#include <fennec/langcpp/startup.h>
|
||||
#include <fennec/lang/strings/string.h>
|
||||
#include <fennec/lang/filesystem/path.h>
|
||||
|
||||
#include <fennec/scene/forward.h>
|
||||
|
||||
#define FENNEC_REGISTER_COMPONENT(T, p) \
|
||||
FENNEC_STATIC_CONSTRUCTOR(T) { \
|
||||
@@ -36,152 +37,15 @@
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class component : public typed<component> {
|
||||
class component {
|
||||
public:
|
||||
|
||||
// TYPEDEFS & CONSTANTS ================================================================================================
|
||||
using component_create = component* (*)(size_t, size_t);
|
||||
using component_destroy = void (*)(component*);
|
||||
|
||||
|
||||
// TYPE OPERATIONS =====================================================================================================
|
||||
|
||||
struct typeinfo {
|
||||
string name;
|
||||
component_create create;
|
||||
|
||||
typeinfo()
|
||||
: name("")
|
||||
, create(nullptr) {
|
||||
}
|
||||
|
||||
typeinfo(const string& name,
|
||||
component_create create)
|
||||
: name(name)
|
||||
, create(create) {
|
||||
}
|
||||
};
|
||||
|
||||
struct typeentry {
|
||||
string name;
|
||||
uint64_t type;
|
||||
};
|
||||
|
||||
using typelist_t = dynarray<optional<typeinfo>>;
|
||||
using typetree_t = rdtree<typeentry>;
|
||||
|
||||
|
||||
// Private Registry ====================================================================================================
|
||||
private:
|
||||
|
||||
static typelist_t _typelist; // Actual list of types
|
||||
static typetree_t _typetree; // Tree for displaying types under subfolders
|
||||
|
||||
static constexpr size_t npos = typetree_t::npos;
|
||||
static constexpr size_t root = typetree_t::root;
|
||||
|
||||
static void _register_type( uint64_t id, const path& path,
|
||||
component_create create) {
|
||||
// Register the type
|
||||
if (id > _typelist.size()) {
|
||||
_typelist.resize(id + 1);
|
||||
}
|
||||
_typelist[id] = typeinfo{ path.filename(), create };
|
||||
|
||||
// Create tree entry
|
||||
size_t node = root;
|
||||
path::iterator it = path.begin();
|
||||
while (it != path.end()) {
|
||||
string name = *it++;
|
||||
size_t parent = node;
|
||||
bool end = it == path.end();
|
||||
|
||||
node = _typetree.child(parent);
|
||||
|
||||
while (node != npos && _typetree[node].type != id) {
|
||||
node = _typetree.next(node);
|
||||
}
|
||||
|
||||
if (node == npos) {
|
||||
node = _typetree.emplace(
|
||||
parent, npos,
|
||||
name, end ? id : nullid
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Default creation function for a component
|
||||
/// \tparam ComponentT Type of the component
|
||||
/// \param node The node to associate the component with
|
||||
/// \returns The component created by this function
|
||||
template<typename ComponentT>
|
||||
static constexpr component* default_create(size_t scene, size_t node) {
|
||||
return new ComponentT(scene, node);
|
||||
}
|
||||
|
||||
|
||||
// Public Registry =====================================================================================================
|
||||
public:
|
||||
|
||||
static constexpr const typetree_t& typelist() {
|
||||
return _typetree;
|
||||
}
|
||||
|
||||
template<typename ComponentT>
|
||||
static constexpr const typeinfo& type_info() {
|
||||
const auto& it = _typelist[id<ComponentT>()];
|
||||
assert(it, "Unregistered type provided to component::type_info, see stacktrace for more info.");
|
||||
return *it;
|
||||
}
|
||||
|
||||
static constexpr const typeinfo& type_info(uint64_t type) {
|
||||
const auto& it = _typelist[type];
|
||||
assert(it, "Unregistered type provided to component::type_info, see stacktrace for more info.");
|
||||
return *it;
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Register a type with the component system
|
||||
/// \tparam ComponentT The component type
|
||||
/// \param path The name of the type
|
||||
/// \param create The function used to create a component, given a scene node. **MUST NOT BE NULL**
|
||||
template<typename ComponentT>
|
||||
static void register_type(const path& path,
|
||||
component_create create = default_create<ComponentT>) {
|
||||
component::_register_type(id<ComponentT>(), path, create);
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Create a component of type `type`
|
||||
/// \param type The type to create
|
||||
/// \param node The node to associate the component with
|
||||
/// \returns The created component
|
||||
static component* create(uint64_t type, size_t scene, size_t node) {
|
||||
auto& typei = _typelist[type];
|
||||
return typei->create(scene, node);
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Create a component of type `type`
|
||||
/// \tparam ComponentT The type to create
|
||||
/// \param node The node to associate the component with
|
||||
/// \returns The created component
|
||||
template<typename ComponentT>
|
||||
static component* create(size_t scene, size_t node) {
|
||||
auto& typei = _typelist[id<ComponentT>()];
|
||||
return typei->create(scene, node);
|
||||
}
|
||||
|
||||
// MEMBERS =============================================================================================================
|
||||
public:
|
||||
const size_t node;
|
||||
scene_node* const node;
|
||||
|
||||
template<typename ComponentT>
|
||||
component(ComponentT* type, size_t node)
|
||||
: typed(type)
|
||||
, node(node) {
|
||||
component(scene_node* node)
|
||||
: node(node) {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
43
include/fennec/scene/forward.h
Normal file
43
include/fennec/scene/forward.h
Normal file
@@ -0,0 +1,43 @@
|
||||
// =====================================================================================================================
|
||||
// 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/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
///
|
||||
/// \file forward.h
|
||||
/// \brief
|
||||
///
|
||||
///
|
||||
/// \details
|
||||
/// \author Medusa Slockbower
|
||||
///
|
||||
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
|
||||
///
|
||||
///
|
||||
|
||||
#ifndef FENNEC_SCENE_FORWARD_H
|
||||
#define FENNEC_SCENE_FORWARD_H
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class scene;
|
||||
struct scene_node;
|
||||
class component;
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_SCENE_FORWARD_H
|
||||
@@ -33,11 +33,23 @@
|
||||
|
||||
#include <fennec/math/matrix.h>
|
||||
#include <fennec/math/ext/transform.h>
|
||||
|
||||
#include <fennec/core/event.h>
|
||||
|
||||
#include <fennec/scene/scene_node.h>
|
||||
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
struct node2d;
|
||||
|
||||
struct transform_update_2d : event {
|
||||
node2d* node;
|
||||
|
||||
FENNEC_RTTI_ENABLE(event);
|
||||
};
|
||||
|
||||
struct node2d : scene_node {
|
||||
// Definitions =========================================================================================================
|
||||
|
||||
@@ -52,8 +64,21 @@ public:
|
||||
|
||||
///
|
||||
/// \brief Default Constructor, initializes an identity matrix.
|
||||
node2d(size_t id, size_t scene, const string& name)
|
||||
: scene_node(name, id, scene)
|
||||
/// \details This is the default node2d constructor, for inheritance, use the typed constructor
|
||||
node2d(fennec::scene* scn, size_t id, const string& name)
|
||||
: scene_node(scn, id, name)
|
||||
, _mobility(mobility_free)
|
||||
, _position(0, 0)
|
||||
, _scale(1, 1)
|
||||
, _shear(0, 0)
|
||||
, _rotation(0) {
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Default Typed Constructor, initializes an identity matrix with proper typing for inheritance.
|
||||
template<typename TypeT>
|
||||
node2d(fennec::scene* scn, size_t id, const string& name, TypeT* type)
|
||||
: scene_node(scn, id, name, type)
|
||||
, _mobility(mobility_free)
|
||||
, _position(0, 0)
|
||||
, _scale(1, 1)
|
||||
@@ -123,7 +148,7 @@ public:
|
||||
// Get parent
|
||||
|
||||
|
||||
_recalculate();
|
||||
|
||||
|
||||
|
||||
// Propagate down
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
#define FENNEC_CORE_SCENE_H
|
||||
|
||||
#include <fennec/containers/rdtree.h>
|
||||
#include <fennec/lang/typed.h>
|
||||
#include <fennec/langproc/strings/string.h>
|
||||
#include <fennec/scene/scene_node.h>
|
||||
#include <fennec/lang/strings/string.h>
|
||||
|
||||
#include <fennec/scene/forward.h>
|
||||
|
||||
|
||||
namespace fennec
|
||||
@@ -33,7 +33,7 @@ namespace fennec
|
||||
/// \details This structure only contains the names of nodes and defers storage for components to
|
||||
/// their respective systems. Simple components may be isolated, \see components.h for more info.
|
||||
/// The hierarchy should be displayed using pre-order traversal.
|
||||
class scene : public rdtree<scene_node*> {
|
||||
class scene : private rdtree<scene_node*> {
|
||||
|
||||
// Access ==============================================================================================================
|
||||
public:
|
||||
@@ -42,44 +42,16 @@ public:
|
||||
/// \details If multiple nodes have the same name, finds the first one in pre-order traversal.
|
||||
/// \param name The name of the node to search for
|
||||
/// \returns The id of the node, `npos` if not found.
|
||||
size_t operator[](const cstring& name) const {
|
||||
list<size_t> parse;
|
||||
parse.push_back(root);
|
||||
while (not parse.empty()) {
|
||||
size_t n = parse.front();
|
||||
if (_table[n].value->name == name) {
|
||||
return n;
|
||||
}
|
||||
|
||||
// Pre-Order traversal
|
||||
parse.push_front(next(n));
|
||||
parse.push_front(child(n));
|
||||
parse.pop_front();
|
||||
}
|
||||
return npos;
|
||||
}
|
||||
scene_node* operator[](const cstring& name) const;
|
||||
|
||||
///
|
||||
/// \brief Find a node by name.
|
||||
/// \details If multiple nodes have the same name, finds the first one in pre-order traversal.
|
||||
/// \param name The name of the node to search for
|
||||
/// \returns The id of the node, `npos` if not found.
|
||||
size_t operator[](const string& name) const {
|
||||
list<size_t> parse;
|
||||
parse.push_back(root);
|
||||
while (not parse.empty()) {
|
||||
size_t n = parse.front();
|
||||
if (_table[n].value->name == name) {
|
||||
return n;
|
||||
}
|
||||
scene_node* operator[](const string& name) const;
|
||||
|
||||
|
||||
// Pre-Order traversal
|
||||
parse.push_front(next(n));
|
||||
parse.push_front(child(n));
|
||||
parse.pop_front();
|
||||
}
|
||||
return npos;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -31,51 +31,32 @@
|
||||
#ifndef FENNEC_SCENE_NODE_H
|
||||
#define FENNEC_SCENE_NODE_H
|
||||
|
||||
#include <fennec/lang/typed.h>
|
||||
#include <fennec/langproc/strings/string.h>
|
||||
#include <fennec/scene/component.h>
|
||||
#include <fennec/lang/strings/string.h>
|
||||
|
||||
#include <utility>
|
||||
#include <fennec/scene/scene.h>
|
||||
#include <fennec/scene/component.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
struct scene_node_ref {
|
||||
size_t scene;
|
||||
size_t id;
|
||||
};
|
||||
|
||||
struct scene_node : typed<scene_node> {
|
||||
struct scene_node {
|
||||
|
||||
// Public Members ======================================================================================================
|
||||
public:
|
||||
union {
|
||||
struct {
|
||||
const size_t scene;
|
||||
const size_t id;
|
||||
};
|
||||
const scene_node_ref ref;
|
||||
};
|
||||
scene* const scene;
|
||||
const size_t id;
|
||||
string name;
|
||||
|
||||
scene_node(size_t scene, size_t id, string name)
|
||||
: scene(scene), id(id), name(std::move(name)) {
|
||||
}
|
||||
|
||||
template<typename ComponentT>
|
||||
component* add_component() {
|
||||
_components.push_back(component::create<ComponentT>(scene, id));
|
||||
return _components.back();
|
||||
}
|
||||
|
||||
component* add_component(uint64_t type) {
|
||||
_components.push_back(component::create(type, scene, id));
|
||||
return _components.back();
|
||||
scene_node(fennec::scene* scn, size_t id, const string& name)
|
||||
: scene(scn), id(id)
|
||||
, name(fennec::move(name)) {
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
dynarray<component*> _components;
|
||||
|
||||
FENNEC_RTTI_ENABLE();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user