Flecs v4.0
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
utils.hpp File Reference

Flecs STL (FTL?) More...

#include <stdlib.h>
#include "array.hpp"
#include "string.hpp"
#include "enum.hpp"
#include "stringstream.hpp"
#include "function_traits.hpp"
Include dependency graph for utils.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  flecs::_::placement_new_tag_t
 
struct  flecs::_::always_false< T >
 

Namespaces

namespace  flecs::_
 Int to enum.
 

Macros

#define FLECS_PLACEMENT_NEW(_ptr, _type)   ::new(flecs::_::placement_new_tag, _ptr) _type
 
#define FLECS_NEW(_type)   FLECS_PLACEMENT_NEW(ecs_os_malloc(sizeof(_type)), _type)
 
#define FLECS_DELETE(_ptr)
 
#define FLECS_MOV(...)    static_cast<flecs::remove_reference_t<decltype(__VA_ARGS__)>&&>(__VA_ARGS__)
 
#define FLECS_FWD(...)    static_cast<decltype(__VA_ARGS__)&&>(__VA_ARGS__)
 
#define flecs_static_assert(cond, str)   static_assert(cond, str)
 

Typedefs

template<bool V, typename T , typename F >
using flecs::conditional_t = typename std::conditional<V, T, F>::type
 
template<typename T >
using flecs::decay_t = typename std::decay<T>::type
 
template<bool V, typename T = void>
using flecs::enable_if_t = typename std::enable_if<V, T>::type
 
template<typename T >
using flecs::remove_pointer_t = typename std::remove_pointer<T>::type
 
template<typename T >
using flecs::remove_reference_t = typename std::remove_reference<T>::type
 
template<typename T >
using flecs::underlying_type_t = typename std::underlying_type<T>::type
 
template<typename T >
using flecs::is_const_p = is_const< remove_pointer_t<T> >
 
template<class Src , class Dst >
using flecs::transcribe_const_t = conditional_t<is_const<Src>::value, Dst const, Dst>
 
template<class Src , class Dst >
using flecs::transcribe_volatile_t = conditional_t<is_volatile<Src>::value, Dst volatile, Dst>
 
template<class Src , class Dst >
using flecs::transcribe_cv_t = transcribe_const_t< Src, transcribe_volatile_t< Src, Dst> >
 
template<class Src , class Dst >
using flecs::transcribe_pointer_t = conditional_t<is_pointer<Src>::value, Dst*, Dst>
 
template<class Src , class Dst >
using flecs::transcribe_cvp_t = transcribe_cv_t< Src, transcribe_pointer_t< Src, Dst> >
 
template<bool V>
using flecs::if_t = enable_if_t<V, int>
 
template<bool V>
using flecs::if_not_t = enable_if_t<false == V, int>
 

Functions

template<class Ty >
void flecs::_::destruct_obj (Ty *_ptr)
 
template<class Ty >
void flecs::_::free_obj (void *_ptr)
 
void * operator new (size_t, flecs::_::placement_new_tag_t, void *_ptr) noexcept
 
void operator delete (void *, flecs::_::placement_new_tag_t, void *) noexcept
 

Variables

constexpr placement_new_tag_t flecs::_::placement_new_tag {}
 

Detailed Description

Flecs STL (FTL?)

Flecs STL (FTL?) Minimalistic utilities that allow for STL like functionality without having to depend on the actual STL.

Definition in file utils.hpp.

Macro Definition Documentation

◆ FLECS_DELETE

#define FLECS_DELETE ( _ptr)
Value:
do { \
if (_ptr) { \
flecs::_::destruct_obj(_ptr); \
ecs_os_free(_ptr); \
} \
} while (false)

Definition at line 21 of file utils.hpp.

◆ FLECS_FWD

#define FLECS_FWD ( ...)     static_cast<decltype(__VA_ARGS__)&&>(__VA_ARGS__)

Definition at line 36 of file utils.hpp.

◆ FLECS_MOV

#define FLECS_MOV ( ...)     static_cast<flecs::remove_reference_t<decltype(__VA_ARGS__)>&&>(__VA_ARGS__)

Definition at line 33 of file utils.hpp.

◆ FLECS_NEW

#define FLECS_NEW ( _type)    FLECS_PLACEMENT_NEW(ecs_os_malloc(sizeof(_type)), _type)

Definition at line 20 of file utils.hpp.

◆ FLECS_PLACEMENT_NEW

#define FLECS_PLACEMENT_NEW ( _ptr,
_type )   ::new(flecs::_::placement_new_tag, _ptr) _type

Definition at line 19 of file utils.hpp.

◆ flecs_static_assert

#define flecs_static_assert ( cond,
str )   static_assert(cond, str)

Definition at line 62 of file utils.hpp.

Typedef Documentation

◆ conditional_t

template<bool V, typename T , typename F >
using flecs::conditional_t = typename std::conditional<V, T, F>::type

Definition at line 74 of file utils.hpp.

◆ decay_t

template<typename T >
using flecs::decay_t = typename std::decay<T>::type

Definition at line 77 of file utils.hpp.

◆ enable_if_t

template<bool V, typename T = void>
using flecs::enable_if_t = typename std::enable_if<V, T>::type

Definition at line 80 of file utils.hpp.

◆ if_not_t

template<bool V>
using flecs::if_not_t = enable_if_t<false == V, int>

Definition at line 134 of file utils.hpp.

◆ if_t

template<bool V>
using flecs::if_t = enable_if_t<V, int>

Definition at line 131 of file utils.hpp.

◆ is_const_p

template<typename T >
using flecs::is_const_p = is_const< remove_pointer_t<T> >

Definition at line 102 of file utils.hpp.

◆ remove_pointer_t

template<typename T >
using flecs::remove_pointer_t = typename std::remove_pointer<T>::type

Definition at line 83 of file utils.hpp.

◆ remove_reference_t

template<typename T >
using flecs::remove_reference_t = typename std::remove_reference<T>::type

Definition at line 86 of file utils.hpp.

◆ transcribe_const_t

template<class Src , class Dst >
using flecs::transcribe_const_t = conditional_t<is_const<Src>::value, Dst const, Dst>

Definition at line 107 of file utils.hpp.

◆ transcribe_cv_t

template<class Src , class Dst >
using flecs::transcribe_cv_t = transcribe_const_t< Src, transcribe_volatile_t< Src, Dst> >

Definition at line 113 of file utils.hpp.

◆ transcribe_cvp_t

template<class Src , class Dst >
using flecs::transcribe_cvp_t = transcribe_cv_t< Src, transcribe_pointer_t< Src, Dst> >

Definition at line 119 of file utils.hpp.

◆ transcribe_pointer_t

template<class Src , class Dst >
using flecs::transcribe_pointer_t = conditional_t<is_pointer<Src>::value, Dst*, Dst>

Definition at line 116 of file utils.hpp.

◆ transcribe_volatile_t

template<class Src , class Dst >
using flecs::transcribe_volatile_t = conditional_t<is_volatile<Src>::value, Dst volatile, Dst>

Definition at line 110 of file utils.hpp.

◆ underlying_type_t

template<typename T >
using flecs::underlying_type_t = typename std::underlying_type<T>::type

Definition at line 89 of file utils.hpp.

Function Documentation

◆ operator delete()

void operator delete ( void * ,
flecs::_::placement_new_tag_t ,
void *  )
inlinenoexcept

Definition at line 66 of file utils.hpp.

◆ operator new()

void * operator new ( size_t ,
flecs::_::placement_new_tag_t ,
void * _ptr )
inlinenoexcept

Definition at line 65 of file utils.hpp.