File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed
Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -582,11 +582,25 @@ class _LIBCPP_STANDALONE_DEBUG __tree_node : public __tree_node_base<_VoidPtr> {
582582public:
583583 using __node_value_type _LIBCPP_NODEBUG = __get_node_value_type_t <_Tp>;
584584
585- union {
586- __node_value_type __value_;
587- };
585+ // We allow starting the lifetime of nodes without initializing the value held by the node,
586+ // since that is handled by the map itself in order to be allocator-aware.
587+ # ifndef _LIBCPP_CXX03_LANG
588+
589+ private:
590+ union {
591+ __node_value_type __value_;
592+ };
593+
594+ public:
595+ _LIBCPP_HIDE_FROM_ABI __node_value_type& __get_value () { return __value_; }
596+ # else
597+
598+ private:
599+ _ALIGNAS_TYPE (__node_value_type) unsigned char __buffer_[sizeof(__node_value_type)];
588600
589- _LIBCPP_HIDE_FROM_ABI __node_value_type& __get_value () { return __value_; }
601+ public:
602+ _LIBCPP_HIDE_FROM_ABI __node_value_type& __get_value () { return *std::__launder (reinterpret_cast <_Tp*>(&__buffer_)); }
603+ # endif
590604
591605 template <class _Alloc , class ... _Args>
592606 explicit __tree_node (_Alloc& __na, _Args&&... __args) {
You can’t perform that action at this time.
0 commit comments