mattreecebentley / plf_colony

An unordered C++ data container providing fast iteration/insertion/erasure while maintaining pointer/iterator validity to non-erased elements regardless of insertions/erasures. Provides higher-performance than std:: library containers for high-modification scenarios with unordered data.
https://plflib.org/colony.htm
zlib License
398 stars 33 forks source link

advice or issue, or change request to revert.... #45

Closed Carandiru0 closed 3 years ago

Carandiru0 commented 3 years ago

Hello!

I've run into an issue that prevents me from updating plf to the newer/latest version.

I use plf colony in a slightly unusual way:

class cBuildingGameObject : public tNonUpdateableGameObject<Volumetric::voxelModelInstance_Static>, public type_colony<cBuildingGameObject>

In this case thru multiple inheritance. I have attached the type_colony and related plf files I have been using. btw, plf is literally awesome.

The problem is a change that prevents me from using it with inheritance.

In the plf_colony.new.h file, lines 279-283

 #ifdef PLF_ALIGNMENT_SUPPORT
typedef typename std::aligned_storage<sizeof(element_type), (sizeof(element_type) >= (sizeof(skipfield_type) * 2) || alignof(element_type) >= (sizeof(skipfield_type) * 2)) ? alignof(element_type) : (sizeof(skipfield_type) * 2)>::type aligned_element_type;
#else
typedef element_type aligned_element_type;
#endif

Which is where the problem lies, as element_type is not defined while using inheritance. eg.)

class C : public type_colony<C>
                       +------------ type_colony<C> contains plf::colony<C>

[type_colony.zip](https://github.com/mattreecebentley/plf_colony/files/6948747/type_colony.zip)
        C is undefined, element type cannot be used before definition.

In the plf_colony.h file this PLF_COLONY_ALIGNMENT_SUPPORT is undefined before inclusion globally in my usage to work-around this issue.

One of the benefits of using inheritance like I have here, is the association with the type. static methods in type_colony access the the internal colony representing all instances of the type it contains. The type it contains can also be overridden in further levels of inheritance. The type safety and access is simplified and directly the type being used for all of it's instances.

Thank you for your time!

mattreecebentley commented 3 years ago

I think I saw your email earlier, unfortunately I don't know how one would fix this. element_type is one of the template parameters, aligned_element_type is necessary to support overaligned types. if you have any ideas let me know.

Carandiru0 commented 3 years ago

ok thanks, If I do come up with something I will post it here. What am I missing by not using alignment btw?

mattreecebentley commented 3 years ago

Nothing, if your type is not overaligned. Although it will fail if your type is < 32bit without alignment.