Bonsoir, j'essaye de définir (prédéclarer pour être plus précis) un template à l'intérieur d'un autre template.

Cf, ce bout de code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
namespace kazu
{
	template<typename scalarT>
	struct	blast
	{
		//vec fwd decl
		class	vec2;
		class	vec3;
		class	vec4;
 
 
		//typedefs
		typedef	scalarT	scalar;
 
		//utility classes
		template<class vecT, unsigned int sizeT>
		class	vecproto;
 
}//namespace kazu
Puis, je définis/précise le template de cette facon:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
template<typename typeT, class selfT, unsigned int dimT>
struct	kazu::blast<typeT>::vecproto<selfT, dimT> :
	public boost::arithmetic< selfT, 
		boost::multiplicative< selfT, typeT,
		kazu::unary<selfT, typeT, dimT,
		kazu::binary<selfT, typeT, dimT,
		kazu::trinary<selfT, typeT, dimT
	> > > > >
{
//	selfT(typeT a[dimT])	{	for (unsigned i = 0; i < dimT; i++){ this->_a[i] = a[i]; }	}
 
	//sum
	inline	typeT	sum()	{	typeT rv = (typeT)0;	for(unsigned int i = 0; i < dimT; i++){rv += this->_a[i];}	return rv;	}
 
	//dot
	virtual	typeT	dot(const selfT& b)	{	selfT rv(*this); rv *= b; return rv.sum(); 	}
	inline	friend	typeT	dot(const selfT& a, const selfT& b)	{	return a.dot(b);	}
 
	//cross
//	virtual	selfT	cross(const selfT& b);	//todo: implement in specialization
	inline	friend	selfT	cross(const selfT& a, const selfT& b)	{	return a.cross(b);	}
 
	//length
	inline	typeT	lensq()	{	selfT a(*this); a *= a; return a.sum();		}
	inline	friend	typeT	lensq(const selfT& a)	{	return	a.lensq();	}
 
	inline	typeT	length()	{	return std::sqrt<typeT>( lensq() );		}
	inline	friend	typeT	length(const selfT& a)	{	return a.length();	}
 
	inline	typeT	distance(const selfT& rhv)	{	selfT a = rhv - (*this); return a.length();	}
	inline	friend	typeT distance(const selfT& a, const selfT& b)	{	return a.distance(b);	}
 
	//operators
	virtual	selfT&	operator=(const selfT& b)	{	for(unsigned int i = 0; i < dimT; i++){this->_a[i] = b._a[i];	}	}
	virtual	selfT&	operator+=(const selfT& b)	{	for(unsigned int i = 0; i < dimT; i++){this->_a[i] += b._a[i];	}	}
	virtual	selfT&	operator-=(const selfT& b)	{	for(unsigned int i = 0; i < dimT; i++){this->_a[i] -= b._a[i];	}	}
	virtual	selfT&	operator*=(const selfT& b)	{	for(unsigned int i = 0; i < dimT; i++){this->_a[i] *= b._a[i];	}	}
	virtual	selfT&	operator/=(const selfT& b)	{	for(unsigned int i = 0; i < dimT; i++){this->_a[i] /= b._a[i];	}	}
 
	virtual	selfT&	operator*=(const typeT b)	{	for(unsigned int i = 0; i < dimT; i++){this->_a[i] *= b;	}	}
	virtual	selfT&	operator/=(const typeT b)	{	for(unsigned int i = 0; i < dimT; i++){this->_a[i] /= b;	}	}
 
	//this ought to crash the compiler, or at least induce errors
//	selfT&	operator+=(const selfT& b)	{	(*this) = (*this) + b;	}
//	selfT&	operator-=(const selfT& b)	{	(*this) = (*this) - b;	}
//	selfT&	operator*=(const selfT& b)	{	(*this) = (*this) * b;	}
//	selfT&	operator/=(const selfT& b)	{	(*this) = (*this) / b;	}
 
	inline	typeT&		operator[](unsigned int idx)	{	assert(idx < dimT); return this->_a[idx];	}
	inline	operator	typeT*()						{	return &this->_a[0];	}
 
	//swizzle
	template<unsigned int X>	inline	typeT&			get()		{	BOOST_STATIC_ASSERT(X < dimT); return this->_a[X];	}
	template<unsigned int X>	inline	const typeT&	get() const	{	BOOST_STATIC_ASSERT(X < dimT); return this->_a[X];	}
 
	template<unsigned int X, unsigned int Y>
	vec2 swizzle2();
	template<unsigned int X, unsigned int Y>
	const vec2 swizzle2() const ;
 
	template<unsigned int X, unsigned int Y, unsigned int Z>
	vec3 swizzle3();
	template<unsigned int X, unsigned int Y, unsigned int Z>
	const vec3 swizzle3() const;
 
	template<unsigned int X, unsigned int Y, unsigned int Z, unsigned int W>
	vec4 swizzle4();
	template<unsigned int X, unsigned int Y, unsigned int Z, unsigned int W>
	const vec4 swizzle4() const;
 
	std::ostream& operator<<(std::ostream& os)
	{
		os << "vec" << dimT << " [";
		for(unsigned int i = 0; i < dimT; i++)
		{	
			if(i)
				os << ", ";
			os << (*this)[i];			
		}
		os << "]";
		return os;
	}
};
et enfin, je me sers du template^2 de cette facon:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
template<typename typeT>
struct kazu::blast<typeT>::vec2 : public kazu::blast<typeT>::vecproto<vec2, 2>
{
	union
	{
		typeT	_a[2];
		struct { typeT x, y; };
		struct { typeT i, a; };
		struct { typeT s, t; };
		struct { typeT _0, _1; };		
	};
 
	vec2()	{}	
	vec2(const vec2& b): x(b.x), y(b.y)	{}
	vec2(typeT _x, typeT _y): x(_x), y(_y)	{}	
	virtual ~vec2(){}
 
	//todo: declare swizzle functions here
	vec2	xx();
	vec3	xxx();
	vec4	xxxx();
 
	const	vec2	xx()	const;
	const	vec3	xxx()	const;
	const	vec4	xxxx()	const;
};
 
template<typename typeT>
struct kazu::blast<typeT>::vec3 : public kazu::blast<typeT>::vecproto<vec3, 3>
{
	union
	{
		typeT	_a[3];
		struct { typeT x, y, z; };
		struct { typeT r, g, b; };
		struct { typeT s, t, p; };
		struct { typeT _0, _1, _2; };		
	};
 
	vec3()	{}	
	vec3(const vec3& b): x(b.x), y(b.y), z(b.z)	{}
	vec3(typeT _x, typeT _y, typeT _z): x(_x), y(_y), z(_z)	{}	
	vec3(const vec2& b): x(b.x), y(b.y), z((typeT)0)	{}
	virtual ~vec3(){}
 
	//todo: declare swizzle functions here
	vec2	xx();
	vec3	xxx();
	vec4	xxxx();
 
	const	vec2	xx()	const;
	const	vec3	xxx()	const;
	const	vec4	xxxx()	const;
};
 
template<typename typeT>
struct kazu::blast<typeT>::vec4 : public kazu::blast<typeT>::vecproto<vec4, 4>
{
	union
	{
		typeT	_a[4];
		struct { typeT x, y, z, w; };
		struct { typeT r, g, b, a; };
		struct { typeT s, t, p, q; };
		struct { typeT _0, _1, _2, _3; };		
	};
 
	vec4()	{}	
	vec4(const vec4& b): x(b.x), y(b.y), z(b.z), w(b.w)	{}
	vec4(typeT _x, typeT _y, typeT _z, typeT _w): x(_x), y(_y), z(_z), w(_w)	{}	
	vec4(const vec2& b): x(b.x), y(b.y), z((typeT)0), w((typeT)1)	{}
	vec4(const vec3& b): x(b.x), y(b.y), z(b.z), w((typeT)1)		{}
	virtual ~vec4(){}
 
	//todo: declare swizzle functions here
	vec2	xx();
	vec3	xxx();
	vec4	xxxx();
 
	const	vec2	xx()	const;
	const	vec3	xxx()	const;
	const	vec4	xxxx()	const;
};
la première erreur que le compilo me lance est celle-ci:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
 error C2992: "kazu::blast<scalarT>::vecproto<selfT,dimT>": Faultive or missing template parameter list.
Je suppose que le truc du template sous template ne fonctionne pas...
C'est bien ca, ou il y a un autre truc qui cloche?