std::vector allocator?

G

Gernot Frisch

Hi,

when should I use std::vector<Type, Type&> and when std::vector<Type,
Type>?
What's the difference?

--
-Gernot
int main(int argc, char** argv) {printf
("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, 'g', 64, "ba", 46, 10);}

________________________________________
Looking for a good game? Do it yourself!
GLBasic - you can do
www.GLBasic.com
 
J

John Harrison

Gernot Frisch said:
Hi,

when should I use std::vector<Type, Type&> and when std::vector<Type,
Type>?
What's the difference?

Neither std::vector<Type, Type&> or std::vector<Type, Type> are legal
(unless, bizarrely, Type is an allocator and you are creating a vector of
allocators).

I think you should post some real code that illustrates what you are getting
at.

john
 
G

Gernot Frisch

Neither std::vector said:
(unless, bizarrely, Type is an allocator and you are creating a vector of
allocators).

I think you should post some real code that illustrates what you are getting
at.

Oh. I'm so sorry. I saw that my intellisense accepted 2 template
arguments and thought it's the same as in MFC's CArray. But since I'm
currently replacing MFC container classes with std:: containers, I
don't even care about what the difference in the MFC version is.
Sorry for wasing your time,
Gernot
 
J

John Harrison

Gernot Frisch said:
Oh. I'm so sorry. I saw that my intellisense accepted 2 template
arguments and thought it's the same as in MFC's CArray. But since I'm
currently replacing MFC container classes with std:: containers, I
don't even care about what the difference in the MFC version is.
Sorry for wasing your time,
Gernot

No problem, the second template argument is for an allocator and you would
use it if you want your vector elements to be allocated in some non-standard
way. For instance (God forbid) you could write an allocator that used
GlobalAlloc instead of new.

john
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top