Topic: Why not have fixed vectors?
Author: boukanov@kvark.fi.uib.no (Igor Boukanov)
Date: 1997/06/28 Raw View
Really, why not have something like
template<typename T, size_t size> class fixed_vector
{
...
typedef T data_array[size];
unsigned char buffer[sizeof(data_array)];
// Memory to place vector elements
// Implementation dependent.
...
}
where ... stands for an adoptation of vector<T> for this
no-memory-allocation case.
Good compilers would inline everything in fixed_vector and built-in arrays
would really become coplitly unnecessary.
The main point to have such class in the standrd is the portability issues:
It is impossible(?) to write such class in the implementaion-independent
way.
So what do you think ?
--
Regards, Igor Boukanov.
igor.boukanov@fi.uib.no
http://www.fi.uib.no/~boukanov/
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]