[color="black"][font="Arial"]Lately, I've been making use of std::vector's'value_type' typedefs in function parameters, so that code written thus;
template<typename TypeA, typename TypeB>
void Foo
(
const TypeA & A,
const TypeB & B
)
{
}
can be rewritten as;
template<typename Type>
void Foo
(
const Type & A,
typename Type::value_type b
)
{
}
for types that deploy the 'value_type' typedef. However, when it comes onto types that are vectors of vectors then code like this;
template<typename Type>
void Foo
(
const Type & A,
typename Type::value_type::size_type b
)
{
}
compiles without any issues, where as the following code;
template<typename Type>
void Foo
(
const Type & A,
typename Type::value_type::value_type b
)
{
}
does not. When nesting value_type like this, my MSV C++ 2010 Express compiler comes up with:
error C2893: Failed to specialize function template 'void Foo(const Type&,Type::value_type::{ctor})
There are obvious work arounds regarding this problem (like simply using another type parameter in the template), but I would just like to know why one type of nesting works and not the other.
And besides... Template programming is a bit of a chink in my C++ armour at the moment, so any opportunity to gain a heads up would be much appreciated![/font]
Yeah... Checked and rechecked my code again. Still no joy!
I even used your version Wooh just to make sure... And it still won't compile...
But thanks japro! That funky work around of yours did do the trick... But it sure is... errr... funky LOL!
In any case, the fact that my "bugged" code compiles for some of you indicates that something might not be right with my compiler (that or it needs upgrading).
Anyway, thanks for replies ;-)
BTW Wooh... Just out of curiosity, what compiler are you using?