mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-08 17:57:02 +08:00
36 lines
888 B
C++
36 lines
888 B
C++
#ifndef ENTT_CORE_FAMILY_HPP
|
|
#define ENTT_CORE_FAMILY_HPP
|
|
|
|
#include "../config/config.h"
|
|
#include "fwd.hpp"
|
|
|
|
namespace entt {
|
|
|
|
/**
|
|
* @brief Dynamic identifier generator.
|
|
*
|
|
* Utility class template that can be used to assign unique identifiers to types
|
|
* at runtime. Use different specializations to create separate sets of
|
|
* identifiers.
|
|
*/
|
|
template<typename...>
|
|
class family {
|
|
static auto identifier() noexcept {
|
|
static ENTT_MAYBE_ATOMIC(id_type) value{};
|
|
return value++;
|
|
}
|
|
|
|
public:
|
|
/*! @brief Unsigned integer type. */
|
|
using value_type = id_type;
|
|
|
|
/*! @brief Statically generated unique identifier for the given type. */
|
|
template<typename... Type>
|
|
// at the time I'm writing, clang crashes during compilation if auto is used instead of value_type
|
|
inline static const value_type value = identifier();
|
|
};
|
|
|
|
} // namespace entt
|
|
|
|
#endif
|