Closed
Description
I noticed this when updating my code from 9e4314e. When entity.component()
is called on a const Entity it looks like a new template instantiation is being created for the const version of the component. This causes the function to return an invalid ComponentHandle. I'm assuming this is a bug and not by design, since I expect you'd just want to return a const ComponentHandle<Component>
in this case, not a ComponentHandle<const Component>
.
I wrote a test to make sure this wasn't just happening in my own app:
TEST_CASE_METHOD(EntityManagerFixture, "TestConstComponentsNotInstantiatedTwice") {
Entity a = em.create();
a.assign<Position>(1, 2);
const Entity b = a;
REQUIRE(a.component<Position>().valid());
REQUIRE(b.component<Position>().valid());
}
Metadata
Metadata
Assignees
Labels
No labels