Fix build with MSVC 14.51. - #353
Conversation
This is required to build geogram on Visual Studio 2026 18.6.0 / MSVC 14.51 , which removes <stdext/hash_map> Note that upstream PoissonRecon seems to have burninated this a long time ago, see mkazhdan/PoissonRecon@9c3c1f8#diff-13ddca840025f5447c61f8ffab0ec0d8199a8f52e22c1bd00e75d5afec320a26 There were more uses in src\lib\geogram\third_party\PoissonRecon\unused\SurfaceTrimmer.cpp.unused but given that it's named ".unused" I assume that fixing it was unnecessary.
4>C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\VC\Tools\MSVC\14.51.36231\include\xmemory(1525,23): error C2440: 'static_cast': cannot convert from 'const _Alloc' to 'GEO::Memory::aligned_allocator<U,64>' [D:\vcpkg\buildtrees\geogram\x64-windows-dbg\src\lib\geogram\third_party\geogram_third_party.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\VC\Tools\MSVC\14.51.36231\include\xmemory(1525,23): error C2440: with [D:\vcpkg\buildtrees\geogram\x64-windows-dbg\src\lib\geogram\third_party\geogram_third_party.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\VC\Tools\MSVC\14.51.36231\include\xmemory(1525,23): error C2440: [ [D:\vcpkg\buildtrees\geogram\x64-windows-dbg\src\lib\geogram\third_party\geogram_third_party.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\VC\Tools\MSVC\14.51.36231\include\xmemory(1525,23): error C2440: _Alloc=GEO::Memory::aligned_allocator<GEO::Numeric::uint8,64> [D:\vcpkg\buildtrees\geogram\x64-windows-dbg\src\lib\geogram\third_party\geogram_third_party.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\VC\Tools\MSVC\14.51.36231\include\xmemory(1525,23): error C2440: ] [D:\vcpkg\buildtrees\geogram\x64-windows-dbg\src\lib\geogram\third_party\geogram_third_party.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\VC\Tools\MSVC\14.51.36231\include\xmemory(1525,23): error C2440: and [D:\vcpkg\buildtrees\geogram\x64-windows-dbg\src\lib\geogram\third_party\geogram_third_party.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\VC\Tools\MSVC\14.51.36231\include\xmemory(1525,23): error C2440: [ [D:\vcpkg\buildtrees\geogram\x64-windows-dbg\src\lib\geogram\third_party\geogram_third_party.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\VC\Tools\MSVC\14.51.36231\include\xmemory(1525,23): error C2440: U=std::_Container_proxy [D:\vcpkg\buildtrees\geogram\x64-windows-dbg\src\lib\geogram\third_party\geogram_third_party.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\VC\Tools\MSVC\14.51.36231\include\xmemory(1525,23): error C2440: ] [D:\vcpkg\buildtrees\geogram\x64-windows-dbg\src\lib\geogram\third_party\geogram_third_party.vcxproj]
(compiling source file '../../../../../src/v1.9.3-f80a2fec58.clean/src/lib/geogram/third_party/PoissonRecon/poisson_geogram.cpp')Not enough :( |
…the rebinding constructor in aligned_allocator.
|
Just an observation: This what Claude told me:
|
|
That's correct. The stdext containers have been effectively obsolete for 15 years at this point. |
|
Thank you very much for this PR ! (I'll merge it soon) Note: I thought that it was working with MSVC 2026, I tested on github using their I am sometimes lost in MSVC versioning, maybe Another question is the rebind allocator, I think it was needed by some compilers / versions of the STL (but I do not exaclty remember, will dig in the archives). I'll also probably make a fork of the original PoissonRecon code and include it here as a submodule, it will make it easier to track modifications (and also make PRs there). |
Yes, 19.6.0 / MSVC 19.51 just came out last week: https://devblogs.microsoft.com/cppblog/msvc-version-1451-available/
I believe that that is the case. Despite technically being in the MSVC team I have intentionally not tried to internalize the new ... "version number scheme" because I don't think real users do that and I want to be able to represent real users.
The rebinding requirement is an STL requirement. That is, given an allocator for type A, the STL needs to be able to construct an allocator for type B. For instance, given Put another way, for some allocator struct _List_node { /* ... */ };
using AllocatorForListNode =
typename std::allocator_traits<A>::template rebind_alloc<_List_node>;
AllocatorForListNode al(a); // <-- the so-called "rebind constructor"
al.allocate(/*...*/);Once upon a time, it looks like geogram implemented this requirement with the conversion operator removed in this PR. However, at some point geogram/src/lib/geogram/basic/memory.h Lines 540 to 543 in 48e5025 got added, and that competes with the conversion operator resulting in ambiguities. ( 4e50010 ? ) The intent of removing the conversion operator is that everything that used that once upon a time now use the rebinding constructor instead.
Is there any chance of using the real one? Vendoring dependencies like that fails as soon as 2 projects do it. |
|
Thank you very much for this pull request ! Will be included in 1.9.10 (to be released soon) |
[PoisonRecon] Remove hash_map.
This is required to build geogram on Visual Studio 2026 18.6.0 / MSVC 14.51 , which removes
<stdext/hash_map>Note that upstream PoissonRecon seems to have burninated this a long time ago, see mkazhdan/PoissonRecon@9c3c1f8#diff-13ddca840025f5447c61f8ffab0ec0d8199a8f52e22c1bd00e75d5afec320a26
There were more uses in src\lib\geogram\third_party\PoissonRecon\unused\SurfaceTrimmer.cpp.unused but given that it's named ".unused" I assume that fixing it was unnecessary.
===========================================
aligned_allocatoralso had an implicit conversion operator that is ambiguous with the rebinding constructor which is removed here.===========================================
AI was not used in preparing this submission.