3D vector

I am trying to initialize a 3D vector in my main program. I am trying to it like this:

1
2
3
4
5
6
        int depth = 600;  //x
	int height = 600; //y
	int width = 600;  //z

	
	vector<vector<vector<float>>> phantom_energy (height, vector<float> (width), vector<vector<float>> (depth));


When I compile I get the following error pertaining to line 6:

Error 24 error C2664: 'std::vector<_Ty>::vector(unsigned int,const _Ty &,const std::allocator<_Ty> &)' : cannot convert parameter 2 from 'std::vector<_Ty>' to 'const std::vector<_Ty> &'

What is going on? Or if you know of a more efficient way to initialize a 3D vector please let me know.
Why a 3D vector? And why do you need 200 million floats?

And didn't you mean to write

 
vector<vector<vector<float>>> phantom_energy (height, vector<vector<float>> (width, vector<float> (depth, 0.0f)));


?
I think you may need to better explain what you're wanting to do, because 600^3 * 4bytes (which is what is going to happen with your approach) is going be almost a 1G memory sink.
Last edited on
Thanks hanst. That seems to work.
Topic archived. No new replies allowed.