473,386 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

std::vector allocator?

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
Jul 22 '05 #1
4 2072

"Gernot Frisch" <Me@Privacy.net> wrote in message
news:2m************@uni-berlin.de...
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
Jul 22 '05 #2
> 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.


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
Jul 22 '05 #3

"Gernot Frisch" <Me@Privacy.net> wrote in message
news:2m************@uni-berlin.de...
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.


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
Jul 22 '05 #4
> you could write an allocator that used
GlobalAlloc instead of new.


Yuck!
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: enzo | last post by:
hi all, i don't understand what's wrong: 1) std::vector<double> p(10); doesn't compile:
11
by: Steve | last post by:
Hi, I'm using a std::vector to store a list of user defined objects. The vector may have well over 1000 elements, and I'm suffering a performance hit. If I use push_back I get a much worse...
20
by: Anonymous | last post by:
Is there a non-brute force method of doing this? transform() looked likely but had no predefined function object. std::vector<double> src; std::vector<int> dest; ...
13
by: linux_bp | last post by:
I have an stl vector array which stores the pointers to objects. To delete the array i am using: std::vector<*foo> bar; .... for (vector<*foo>::iterator itr = bar.begin(); itr != bar.end(); )...
9
by: aaragon | last post by:
I am trying to create a vector of type T and everything goes fine until I try to iterate over it. For some reason, the compiler gives me an error when I declare std::vector<T>::iterator iter;...
3
by: mast2as | last post by:
sorry i am too sure how to write a more explicit subject but this code doesn't compile for the type string and I am not sure why (and I am not sure either how to describe the problem but by looking...
13
by: jubelbrus | last post by:
Hi I'm trying to do the following. #include <vector> #include <boost/thread/mutex.hpp> #include <boost/shared_ptr.hpp> #include <boost/tuple/tuple.hpp> class {
3
by: DevNull | last post by:
I have a program where we load a mapfile, comprised of a .csv with numbers which represent object types at a given position. Each position is in the map is called a Cell, a cell contains only a...
8
by: jacek.dziedzic | last post by:
Hi! I need to be able to track memory usage in a medium-sized application I'm developing. The only significant (memory-wise) non- local objects are of two types -- std::vector<and of a custom...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.