Closed colugomusic closed 1 year ago
Thank you!
Unfortunately this fix seems to be required for MSVC C++20 mode, but breaks when compiling in C++17 mode. In C++17 the old vp->~T()
compiles fine. No idea if it's a compiler bug or what. An #ifdef
on the standard version might be the only thing we can do to support both. What do you think?
Weird... C++17 also introduces std::destroy_at
, maybe you can try that? (We need to ifdef that also anyway for C++14 support though).
More findings (you won't like it.) I have some old code that looks like this:
struct SnapshotBlock {
ID id{};
engine::state::BlockState state;
};
struct SnapshotLane {
ID id{};
immer::vector<ID> blocks;
};
...
struct Snapshot {
struct Data {
...
immer::table<SnapshotBlock> blocks;
immer::table<SnapshotLane> lanes;
...
};
...
};
This works fine in C++17 mode with the old version of immer I was using (006461c). After switching to C++20 mode I get the error C2059. After updating immer to the latest version something truly remarkable happens...
immer/detail/hamts/node.hpp(300,29): error C2523: 'sn::SnapshotBlock::~SnapshotLane': destructor tag mismatch (compiling source file Z:\dv\blockhead\back\src\blocks\base\base_active_block.cpp)
This is referring to that explicit destructor call on line 300: vp->T::~T();
Somehow MSVC has got completely confused and now believes that T
is both SnapshotBlock
and SnapshotLane
.
The error goes away if I comment out the places where I insert into the tables elsewhere in the code. I'll try my best to create a minimal reproduction case but Microsoft's compiler is either really broken or the latest version of immer is doing something really bad. Either way I don't really trust the fix I made in this PR anymore.
Weird... C++17 also introduces
std::destroy_at
, maybe you can try that? (We need to ifdef that also anyway for C++14 support though).
This appears to be the answer! I will submit another pull request but I want to do a lot more testing first and see if I can get both of my projects building.
Cool, thanks!
The following code from your documentation:
Will produce the following error in MSVC when attempting to zoom in on the map element:
Qualifying the explicit destructor call with
T::
satisfies the compiler.