The subject of templates in C++ is still a weak point for me. If I had
slept in the past 24 hours, I might be able to figure this out myself,
nonetheless, I'll go ahead and ask.
I'm trying to create a type which is formed of a boost::array of
boost::arrays of boost::arrays of 3 float elements. The table below
demonstrates the idea. Assume x, y and z are float:
vf[x, y, z][1, 1] vf[x, y, z][1, 2] vf[x, y, z][1, 3] vf[x, y, z][1, 4]
vf[x, y, z][2, 1] vf[x, y, z][2, 2] vf[x, y, z][2, 3] vf[x, y, z][2, 4]
vf[x, y, z][3, 1] vf[x, y, z][3, 2] vf[x, y, z][3, 3] vf[x, y, z][3, 4]
vf[x, y, z][4, 1] vf[x, y, z][4, 2] vf[x, y, z][4, 3] vf[x, y, z][4, 4]
vf[x, y, z][5, 1] vf[x, y, z][5, 2] vf[x, y, z][5, 3] vf[x, y, z][5, 4]
I want to be able to specify the size when the object is instantiated. The
following results in an error when I try to compile it:
typedef array<float,3> Vec3f;
typedef array<Vec3f> Field3f;
It says mean things such as:
/************************************************** ************/
In file included
from /home/hattons/code/c++/gs/vertices/src/vertexfield.cpp:20:
/home/hattons/code/c++/gs/vertices/src/vertexfield.h:27: error: wrong number
of
template arguments (1, should be 2)
/home/hattons/opt/org/boost/include/boost-1_31/boost/array.hpp:38: error:
provided
for `template<class T, unsigned int N> class boost::array'
/************************************************** ************/
My compiler is quite pleased with this:
using boost::array;
typedef array<float,3> Vec3f;
const unsigned N=5;
typedef array<Vec3f, N> Field3f;
Is there a way I can create something that acts like a type definition that
accepts a const unsigned when I'm ready to provide it?
--
STH
Hatton's Law: "There is only One inviolable Law"
KDevelop: http://www.kdevelop.org SuSE: http://www.suse.com
Mozilla: http://www.mozilla.org