shared pipe hlxSweExam
#include <cstdlib> #include <new> template <class T> struct Mallocator { typedef T value_type; Mallocator() = default; template <class U> constexpr Mallocator(const Mallocator<U>&) noexcept {} [[nodiscard]] T* allocate(std::size_t n) { if(n > std::size_t(-1) / sizeof(T)) throw std::bad_alloc(); if(auto p = static_cast<T*>(std::malloc(n*sizeof(T)))) return p; throw std::bad_alloc(); } void deallocate(T* p, std::size_t) noexcept { std::free(p); } }; template <class T, class U> bool operator==(const Mallocator<T>&, const Mallocator<U>&) { return true; } template <class T, class U> bool operator!=(const Mallocator<T>&, const Mallocator<U>&) { return false; } https://elloop.github.io/c++/2016-09-19/stl-apply-imp-95-simple-allocator http://www.cnblogs.com/suzhou/p/5381738.html http://www.justskins.com/forums/shm_open-vs-open-253314.html http://www.drdobbs.com/creati...