ROOT CAUSE:
The allocate() function was incorrectly constructing objects during memory
allocation, violating C++ allocator requirements. MSVC's std::_Tree_node has
a deleted default constructor, causing compilation failure.
CHANGES:
1. container_allocator::allocate() - Now only allocates raw memory without
constructing objects (removed mem::$new and ipc::construct calls)
2. container_allocator::deallocate() - Now only frees memory without
destroying objects (removed mem::$delete and ipc::destroy_n calls)
WHY THIS FIXES THE ISSUE:
- C++ allocator semantics require strict separation:
* allocate() -> raw memory allocation
* construct() -> object construction
* destroy() -> object destruction
* deallocate() -> memory deallocation
- std::map and other containers call construct() with proper arguments
(key, value) to initialize nodes, not allocate()
- std::_Tree_node in MSVC has no default constructor (= delete), so
attempting to construct it without arguments always fails
- The previous code tried to default-construct objects in allocate(),
which is both semantically wrong and impossible for _Tree_node
PREVIOUS FIX (uninitialized.h):
The earlier fix to uninitialized.h was insufficient - even with correct
T() vs T{} handling, you cannot default-construct a type with deleted
default constructor.
Fixes MSVC 2017 compilation error:
error C2280: attempting to reference a deleted function
The issue occurs when container_allocator calls ipc::construct<T>() with no arguments.
MSVC and GCC have different behaviors regarding std::is_constructible for std::map's
internal node type.
Solution:
- Add explicit overload for zero-argument construct() using value initialization T()
- Separate overloads for one or more arguments to avoid SFINAE ambiguity
- This ensures MSVC uses direct initialization T() instead of aggregate initialization T{}
Fixes compilation error on Visual Studio 2017:
error C2512: no appropriate default constructor available
note: Invalid aggregate initialization