Entix’s core types#

Basic integer types

#include <Entix/Core/Types.h>
namespace Entix#

Typedefs

using Int8 = int8_t#
using Int16 = int16_t#
using Int32 = int32_t#
using Int64 = int64_t#
using Uint8 = uint8_t#
using Uint16 = uint16_t#
using Uint32 = uint32_t#
using Uint64 = uint64_t#
using Usize = size_t#
using Any = ::std::any#

Id template type

#include <Entix/Core/Types.h>
template<typename T, typename Tag>
class Id#

Id template type.

Usage example:

struct MyIdTag {};
struct MyIdTag2 {};

void IdTest()
{
     Id<Usize, MyIdTag> myId = 10;
     Id<Usize, MyIdTag2> myId2 = 10;

     // This is error. You can't compare different Id types implicitly
     if(myId == myId2)
     {
         // Do something...
     }

     // Following convertion are acceptable.
     //
     // Convertion are available when Id type
     // are convertable or the same (std::is_convertible_v || std::is_same_v)
     if(myId == (Id<Usize, MyIdTag>)myId2)
     {
         // Do something...
     }
}

Following code doing the same but with macro:

EX_DEFINE_ID_TYPE(MyId);
EX_DEFINE_ID_TYPE(MyId2);

void IdTest()
{
     MyId myId = 10;
     MyId2 myId2 = 10;

     // This is error. You can't compare different Id types implicitly
     if(myId == myId2)
     {
         // Do something...
     }

     // Following convertion are acceptable.
     //
     // Convertion are available when Id type
     // are convertable or the same (std::is_convertible_v || std::is_same_v)
     if(myId == (MyId)myId2)
     {
         // Do something...
     }
}

Template Parameters:
  • T – Id unsigned integer type (std::is_unsigned_v<T> is required)

  • Tag – For different Id types. Tag must be empty structure (std::is_empty_v<Tag> is required)

Public Functions

inline constexpr Id(T value)#
inline constexpr T Get() const noexcept#
inline T &operator*() noexcept#
inline bool operator==(const Id<T, Tag> &other) const noexcept#
inline bool operator!=(const Id<T, Tag> &other) const noexcept#
template<typename OtherT, typename OtherTag>
inline explicit operator Id<OtherT, OtherTag>() const noexcept#
struct Hasher#

Hasher struct for Id type.

Usage example:

// Type definitions
EX_DEFINE_ID_TYPE(PlayerId);
struct Player {};

// Somewhere in your class or function
std::unordered_map<PlayerId, Player, PlayerId::Hasher> players;

Public Functions

inline Usize operator()(const Id<T, Tag> &id)#
EX_DEFINE_ID_TYPE(NAME)#

Defines Id type from template.

Creates a empty tag structure and defines Id type with following template parameters: Id<Usize, TAG_STRUCTURE>

Parameters:
  • NAME – [in] You Id type name. Tag structure are named as NAME##Tag


Basic string types

#include <Entix/Core/String.h>
namespace Entix

Typedefs

using String = std::string#
using StringView = std::string_view#