I am trying to learn STL allocators for void*. Here is my code
#include <set>
#include <memory>
class Test {
public:
std::set<void*> GetAllInformation() { return info_set_; }
private:
std::set<void*> info_set_;
};
int main() {
std::unique_ptr<Test> test_obj_;
const auto info = test_obj_->GetAllInformation();
if (info.empty())
std::cout << "info empty";
return 0;
}
But I am getting Segmentation fault at
Thread 1 received signal SIGSEGV, Segmentation fault.
0x00402a18 in std::_Rb_tree<void*, void*, std::_Identity<void*>, std::less<void*>, std::allocator<void*> >::_M_root (this=0x0) at C:/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/lib/gcc/i686-w64-mingw32/8.1.0/include/c++/bits/stl_tree.h:733
The stl_tree.h
_Const_Base_ptr
_M_root() const _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_header._M_parent; }
could anyone help to explain? Thanks