Hi I am new to vectors in cpp, when I compiled the below code I get this following error. What does this mean and what the code is doing ??
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
template <typename T>
struct aligned_allocator
{
typedef T value_type;
T* allocate(std::size_t num)
{
void* ptr = nullptr;
if (posix_memalign(&ptr,4096,num*sizeof(T)))
throw std::bad_alloc();
return reinterpret_cast<T*>(ptr);
}
void deallocate(T* p, std::size_t num)
{
free(p);
}
};
int main() {
bool ignore_dc = true;
const size_t blocks = 1024*1024*4;
std::vector< int16_t, aligned_allocator<int16_t> > source_block(64*blocks);
}
|
error: no class template named ‘rebind’ in ‘struct aligned_allocator<short int>’
/proj/xbuilds/2017.4_0206_1/installs/lin64/Vivado/2017.4/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_vector.h: In instantiation of ‘std::vector<short int, aligned_allocator<short int> >’:
error: no members matching ‘std::vector<short int, aligned_allocator<short int> >::_Base {aka std::_Vector_base<short int, aligned_allocator<short int> >}::_M_allocate’ in ‘std::vector<short int, aligned_allocator<short int> >::_Base {aka struct std::_Vector_base<short int, aligned_allocator<short int> >}’
error: no members matching ‘std::vector<short int, aligned_allocator<short int> >::_Base {aka std::_Vector_base<short int, aligned_allocator<short int> >}::_M_deallocate’ in ‘std::vector<short int, aligned_allocator<short int> >::_Base {aka struct std::_Vector_base<short int, aligned_allocator<short int> >}’
stl_vector.h:209:20: error: no members matching ‘std::vector<short int, aligned_allocator<short int> >::_Base {aka std::_Vector_base<short int, aligned_allocator<short int> >}::_M_get_Tp_allocator’ in ‘std::vector<short int, aligned_allocator<short int> >::_Base {aka struct std::_Vector_base<short int, aligned_allocator<short int> >}’
stl_vector.h: In destructor ‘std::vector<_Tp, _Alloc>::~vector() [with _Tp = short int, _Alloc = aligned_allocator<short int>]’: