Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is a "valid entity type"? (Question) #1111

Closed
Batres3 opened this issue Feb 3, 2024 · 2 comments
Closed

What is a "valid entity type"? (Question) #1111

Batres3 opened this issue Feb 3, 2024 · 2 comments
Assignees
Labels
question open question solved available upstream or in a branch

Comments

@Batres3
Copy link

Batres3 commented Feb 3, 2024

According to the documentation: "User defined identifiers are allowed as enum classes and class types that define an entity_type member of type std::uint32_t or std::uint64_t."

I'm quite a beginner when it comes to C++ so I don't really understand what this means. In the faq the example given is:

enum class entity: std::uint32_t {};

What would a valid example look like for a custom entity that is not an enum class, but a regular class?

I'm trying to make it work with the following class:

class UUID
{
public:
	using entity_type = uint64_t;
	static constexpr uint64_t null = 0;
	UUID();
	UUID(uint64_t id);
	UUID(const UUID&) = default;

	constexpr operator entity_type() const noexcept { return m_UUID; }
private:
	entity_type m_UUID;
};

This is obviously not correct since it raises the error

error C2127: 'value': illegal initialization of 'constexpr' entity with a non-constant expression

But I don't understand what has to be constant here. Sorry if this has been asked before but I couldn't quite find it.

@skypjack skypjack self-assigned this Feb 4, 2024
@skypjack skypjack added the question open question label Feb 4, 2024
@skypjack
Copy link
Owner

skypjack commented Feb 4, 2024

Is this what you are looking for?

@Batres3
Copy link
Author

Batres3 commented Feb 6, 2024

That's exactly it, thank you and sorry for the late response.

@Batres3 Batres3 closed this as completed Feb 6, 2024
@skypjack skypjack added the solved available upstream or in a branch label Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question open question solved available upstream or in a branch
Projects
None yet
Development

No branches or pull requests

2 participants