tags:

views:

503

answers:

1

This is a snippet of a class template which is causing compilation errors:

/* Secondary index class */
template<class TKey, class TVal, class key_traits, class val_traits>
template<class TSecKey, class sktraits> 
class CBtreeDb<TKey, TVal, key_traits, val_traits>::CDbSecondaryIndex: protected CBtreeDb<TKey, TVal>, public IDeallocateKey
{
public:
 typedef TSecKey           skey_type;
 typedef typename sktraits                         skey_traits;
 typedef CNewDbt<TSecKey, sktraits>                CDbSKey;
 typedef typename iterator_t<TSecKey, skey_traits> iterator;
 typedef typename iter_lower_bound_t<skey_type>    iter_lower_bound;
 typedef typename iter_upper_bound_t<skey_type>    iter_upper_bound;

 CDbSecondaryIndex(CDbEnv* pEnv, u_int32_t flags, bool bAllowDuplicates=false):
  CBtreeDb(pEnv, flags, bAllowDuplicates)
 {

 }

    // Class implementation continues ...
};

The compiler error message I get is:

expected nested-name-specifier before 'sktraits'.

Actually, this error occurs on every typedef declaration followed by typename

I have compiled this code succesfully in the past using VS2005 and VS2008 on XP.

I am currently building on Ubuntu 9.10, using gcc 4.4.1

I looked this error up on Google and it appears that the typename isn't necessary on the line (where the error occurs), because the standard assumption is that an identifier in that position is a type. g++ seems to be complaining because it expects any typename declaration there to be qualified (i.e. A::B).

Is this is a correct diagnosis of the problem - if so, then how do I "fully qualify" the typename?

In short, how may I resolve this problem ?

+1  A: 

The following is not allowed:

template<class A>
template<class B> class F { ... };

You can have at most one template<> specification before a class/function definition.

dirkgently