const vector<A> vs vector<const A> vs const vector<const A>

const vector<A> vs vector<const A> vs const vector<const A>

Post by Javie » Thu, 06 Sep 2007 02:53:45


Hello,
thanks for the replies to my questions.
I have one more:
class A
{
public:
m1() const;
m2();
};

is there any difference between

std::vector<const A> v;
const std::vector<A> v;
const std::vector<const A> v;

and, what about:

A a1;
v.push_back(a1);
v[0].m1()
v[0].m2()

in the three cases?
 
 
 

1. const vector<A> vs vector<const A> vs const vector<const A>

2. vector<const T(*)> vs. vector<T(*)>

Hi all,

I'm facing some uncertainty with const template arguments.
Maybe someone could explain the general strategy.


#include <vector>

int main(int arc, char** argv)
{
std::vector<const int> vec;
const int i = 5;
vec.push_back(i);
vec[0] = 4; //const has gone away

std::vector<const int*> pvec;
const int* pi = new int(5);
pvec.push_back(pi);
*(pvec[0]) = 4; // not possible because const, compile error

return 0;
}

From the first impression, it is not possible to create a vector of
const ints.
But you can do it with pointers.

3. <h1><a></a></h1> or <a><h1></h1></a>

4. Cast vector<foo*> to vector<const foo*>?

5. Getting dotted line around .GIF image used in <A></A> tag

6. text getting stripped on upload from within <a></a>

7. What can be inside an <a></a> tag?

8. Google: Do you mean <A>Zone</A>?

9. <A> Cannot be a Container for <A>?

10. Position of <a>text</a>

11. Tag behavior <A> onClick (what does <A> mean?

12. Question about a static vector<*A> in class A

13. vector<T> v.s. vector<T,allocator>

14. template function (vector<int> vs. vector<gsl_vector*>)

15. vector<const string> not allowed?