Replace STL allocator with custom allocator

2020-05-07 08:45发布

问题:

I followed this link: Replace default STL allocator

to replace the standard allocator with my own custom allocator. But I am getting this error:

/grid/common/pkgsData/gcc-v4.8.3/Linux/RHEL5.0-2010-x86_64/include/c++/4.8.3/bits/allocator.h:92:45: error: expected template-name before '<' token

class allocator: public __allocator_base<_Tp>
                                         ^

Somehow allocator.h file is not able to find out my custom allocator class. I used GCC:4.8.3 I added bits/ folder inside my source include folder, and created c++allocator.h. Inside this file defined marco similar to GCC provided c++allocator.h (https://gcc.gnu.org/onlinedocs/gcc-4.6.2/libstdc++/api/a00780_source.html).

#define __glibcxx_base_allocator my_allocator

my_allocator is my custom allocator.