Skip to content

Commit

Permalink
Fix shared_ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumeAbel committed Sep 20, 2023
1 parent cd82d9c commit 7255412
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/poc/src/Registry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
class Registry {
public:
template <class Component>
using array = std::shared_ptr<SparseArray<Component>>;
using array = SparseArray<Component> &;

template <class Component>
array<Component> registerComponent()
{
if (_data.find(typeid(Component)) == _data.end()) {
_data[typeid(Component)] = std::make_shared<SparseArray<Component>>();
_data[typeid(Component)] = SparseArray<Component>();
}
return castReturn<Component>();
};
Expand Down
16 changes: 8 additions & 8 deletions src/poc/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
int main()
{
Registry registry;
Registry::array<int> arrInt = registry.registerComponent<int>();
arrInt->add(4);
arrInt->add(69);
Registry::array<float> arrFloat = registry.registerComponent<float>();
arrFloat->add(69.69);
Registry::array<float> scdContainer = registry.getComponents<float>();
for (auto begin = arrInt->begin(); begin != arrInt->end(); begin++) {
Registry::array<int> &arrInt = registry.registerComponent<int>();
arrInt.add(4);
arrInt.add(69);
Registry::array<float> &arrFloat = registry.registerComponent<float>();
arrFloat.add(69.69);
Registry::array<float> &scdContainer = registry.getComponents<float>();
for (auto begin = arrInt.begin(); begin != arrInt.end(); begin++) {
std::cout << *begin << std::endl;
}
for (auto begin = scdContainer->begin(); begin != scdContainer->end(); begin++) {
for (auto begin = scdContainer.begin(); begin != scdContainer.end(); begin++) {
std::cout << *begin << std::endl;
}
return 0;
Expand Down

0 comments on commit 7255412

Please sign in to comment.