I have a fuction that takes a vector as a parameter.
I want to be able to have a default value so I'm not required to pass anything if I don't need to.
I pass vectors by reference because of some things I need to do with it that pointers don't do.
anyway
I can define my function like this
func(vector<unsigned int> foo = vector<unsigned int>());
and everthing is fine, however if I define like this,
func(vector<unsigned int>& foo = vector<unsigned int>());
I get
error: invalid type `std::vector<unsigned int, std::allocator<unsigned int> >' for default argument to ` std::vector<unsigned int, std::allocator<unsigned int> >&'
I am running SuSE 9.1 2.6.5-7.145-default
This syntax works with Borland 6 windoze (disclaimer: no, not mine, co-worker's)
the only work-around I've come up with is to declare a global variable
vector<unsigned int> g_empty_vec;
then use that func(vector<unsigned int>& foo = g_empty_vec);
I'd like something a little cleaner if possible....
Thanks in advance,
B-)