Comments (6)
Have you tried it already in your project? Can you confirm that it works as expected?
from entt.
Yes! But if there are other places where EnTT is using a placement new, those may also need to be updated. Happy to work on a MWE without Jolt if you think that's useful.
from entt.
The only other class that uses placement new is any
afaik.
I don't think a MWE with Jolt is required here actually. A standalone test that doesn't use external libraries would be way better to avoid future regression probably.
Do you have bandwidth to pack something in this sense for the utility in memory.hpp
? A rough example would be enough, I can then fix it and throw it in myself but it would definitely save me a lot of time!
from entt.
Sure. As I said I was planning to provide a MWE without Jolt. So here it is:
#include <entt/entt.hpp>
#include <stdlib.h>
#include <cstdlib>
namespace MyLib {
void* Allocate(size_t inSize)
{
return malloc(inSize);
}
void Free(void* inBlock)
{
free(inBlock);
}
void* AlignedAllocate(size_t inSize, size_t inAlignment)
{
#if defined(_WIN32)
return _aligned_malloc(inSize, inAlignment);
#else
void* block = nullptr;
posix_memalign(&block, inAlignment, inSize);
return block;
#endif
}
void AlignedFree(void* inBlock)
{
#if defined(_WIN32)
_aligned_free(inBlock);
#else
free(inBlock);
#endif
}
class Foo
{
public:
Foo(int x_)
: x(x_)
{}
public:
void* operator new(size_t inCount) { return MyLib::Allocate(inCount); }
void operator delete(void* inPointer) noexcept { MyLib::Free(inPointer); }
void* operator new[](size_t inCount) { return MyLib::Allocate(inCount); }
void operator delete[](void* inPointer) noexcept { MyLib::Free(inPointer); }
void* operator new(size_t inCount, std::align_val_t inAlignment)
{
return MyLib::AlignedAllocate(inCount, static_cast<size_t>(inAlignment));
}
void operator delete(void* inPointer, [[maybe_unused]] std::align_val_t inAlignment) noexcept
{
MyLib::AlignedFree(inPointer);
}
void* operator new[](size_t inCount, std::align_val_t inAlignment)
{
return MyLib::AlignedAllocate(inCount, static_cast<size_t>(inAlignment));
}
void operator delete[](void* inPointer, [[maybe_unused]] std::align_val_t inAlignment) noexcept
{
MyLib::AlignedFree(inPointer);
}
protected:
int x;
};
} // namespace MyLib
int main(void)
{
entt::registry r;
auto e = r.create();
r.emplace<MyLib::Foo>(e, 42); // <-- doesn't compile
return 0;
}
from entt.
As I said I was planning to provide a MWE without Jolt
You're right and I read it wrong. 😅
Thanks for the example, I'll use it as the basis for a non-regression test. 👍
from entt.
All good, thanks for looking into it!
from entt.
Related Issues (20)
- Serialization of "dead" components
- C++20 ranges trait specializations
- Efficiently iterating over a set of groups? HOT 2
- Signals not triggering properly in storage mixin iterator based insert HOT 2
- Access violation when using registry.clear<Component>() HOT 9
- Is it possible to use entt::nth_argument_t with lambdas that capture? HOT 6
- Question it is posible to use Entt with lightweight wrapper class as a entt::entity HOT 2
- Calling valid() on empty entt::valid leads to a segmentation fault.
- Add ability to compare entt::null and entt::handle
- sparse_set_iterator::operator[] causes warnings when used with size_t HOT 6
- Working with multiple storages for the same type and preparing a view for each of the storages HOT 3
- entt build error: unused type alias 'common_type' HOT 9
- assert on destroy (inside of release function) non-orphan entity HOT 8
- Handling large tilemap HOT 7
- Acecss components of an entity, without giving full registry access HOT 14
- bazel version and compatibility number out of sync
- storage<entt::entity>("id"_hs) should be asserted against HOT 2
- Get a view of components with a certain trait HOT 1
- Groups not functioning without sigh_mixin
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from entt.