+6  A: 

Yes there is something in the standard stopping using arrays Using Draft C++98 Standard

Section 23 Containers

The type of objects stored in these components must meet the requirements of CopyConstructible types (20.1.3), and the additional requirements of Assignabletypes.

where components are various containers

20.1.3 includes the requirement that the type has to have a destructor.

I think of it as a vector has to copy allocate and delete elements. How does C++ know to copy or delete a char[] ?

Mark
Thanks for the reference, good job. Should have found it myself, but was too block-headed. Other answers are correct, too, I am marking this, since it was the fastest.regards martin
martin
I'm sure you're misreading it. `std::vector<int>` is very legal even though int has no destructor either.
MSalters
You can do x = new int(5): delete x; - but to delete an array you need delete []
Mark
A: 

Please let me know mind of this code. You already know, vector is also some kind of an array and you dont have to give initial size.

1D vector  ->  std::vector<char*> ca_vector;
2D vector  ->  std::vector<char*,char*> ca_vector;
Aykut
Hello, thank you for the answer. I am aware that the vector can be used as an array, as you have correctly pointed out. What I wanted to know is if the above code is legal in the sense of the standard. I could have put a vector of strings vector<string> there but as Mark has written, an basic C/C++ array does not fulfill the the requirements on container elements.
martin
@Aykut: std::vector<char*,char*> doesn't make any sense.
sellibitze
The second template argument to vector is not the type of the second dimension (vectors only have one dimension). The second argument is the allocate (defaulting to the standard allocator).
turdfurguson
a 2D vector would look something like: std::vector<std::vector<char*> >
Jonas
i am really sorry about my wrong comment. I dont know what i was thinking while writing this comment. I deserve -1. :(
Aykut
+1  A: 

Nope, this is not allowed, just like it wasn't allowed in the question you linked to (and I don't see how the "reason is different"). It's not a "bug" in either of the two questions. Or at least, not a bug in the compiler. Just in your code. ;)

You can't store an array in a vector, because a vector requires its elements to be copy-constructible and assignable.

jalf
+1  A: 

The easiest solution to do this is:

std::vector<boost::array<LENGTH> > ca_vector;

This way you don't have to bother with the array/pointer story. Whether you really want this, is another question.

stefaanv
Thanks for the input. In fact in my concrete case vector<string> is the (probably intended) solution to the problem in the (legacy) source code I am reviewing (so it's not raw bytes or anything but just strings). I am not at all sure why there even is a char[]-array and not a string, when there is already a vector; I can only imagine some obscure (and probably misguided) optimization considerations on part of the original author...
martin
If it is a string, use a string. I used my construction as a temporary solution to store byte-based messages in an stl-container.
stefaanv
or std::vector<std::tr1::array<LENGTH> > ca_vector;
turdfurguson