I'm getting a compile error on vs2005 that I dont understand. The
help
explains that this is a breaking change for VC++.NET 2005 compiler,
made in
order to conform to the ISO C++ standard, and I've tried it using evc+
+ 4.0 sp4 and
it compiles ok.

Code is as follows.............

//paramstring.h

template <class T> class ParameterStringAW
{
public:
typedef T* PT;
typedef const T* PCT;

class CKeyValuePair
{

protected:
TString m_strKey;
TString m_strValue;
BOOL m_bIgnoreCase;

public:
CKeyValuePair(PCT szKey, PCT szValue, BOOL bIgnoreCase) :
m_strKey(szKey), m_strValue(szValue),m_bIgnoreCase(bIgnoreCase)
{
}
~CKeyValuePair()
{
}
PCT GetValue() const
{
return m_strValue.c_str();
}
void SetValue( PCT szValue )
{
m_strValue = szValue;
}
PCT GetKey() const
{
return m_strKey.c_str();
}
BOOL Is( PCT szKeyToCompare) const
{
if (NULL == szKeyToCompare)
return FALSE;

if (m_bIgnoreCase)
return (0 == CompareNoCase(m_strKey, TString(szKeyToCompare)));
else
return ( m_strKey == szKeyToCompare );
}
};

typedef CKeyValuePair* PKeyValuePair;
typedef std::vector< PKeyValuePair > KeyValueList;


};

/
***********************************************************************************************************/
paramstring.cpp

template <class T>
ParameterStringAW<T>::PKeyValuePair ParameterStringAW<T>::Exists( PCT
szKey ) const // this is the line where i get errors...
{


}

warning C4346: 'ParameterStringAW<T>::PKeyValuePair' : dependent name
is not a type
prefix with 'typename' to indicate a type

error C2143: syntax error : missing ';' before
'ParameterStringAW<T>::Exists'

error C1903: unable to recover from previous error(s); stopping
compilation NMUTF8.cpp

Any insight would be appreciated.

Re: Compile error:dependent name is not a type by Ulrich

Ulrich
Thu Dec 13 05:30:06 PST 2007

sanil wrote:
[...]
> template <class T>
> ParameterStringAW<T>::PKeyValuePair
> ParameterStringAW<T>::Exists( PCT szKey ) const
[...]
> warning C4346: 'ParameterStringAW<T>::PKeyValuePair' : dependent name
> is not a type prefix with 'typename' to indicate a type
^^^^^^^^^^^^^^^^^^^^^^

You must use 'typename' for dependent types, the MSDN page for C4346
explains that further, see msdn.microsoft.com.

cheers

Uli


Re: Compile error:dependent name is not a type by sanil

sanil
Thu Dec 13 05:46:34 PST 2007

On Dec 13, 6:30 pm, Ulrich Eckhardt <eckha...@satorlaser.com> wrote:
> sanil wrote:
>
> [...]> template <class T>
> > ParameterStringAW<T>::PKeyValuePair
> > ParameterStringAW<T>::Exists( PCT szKey ) const
> [...]
> > warning C4346: 'ParameterStringAW<T>::PKeyValuePair' : dependent name
> > is not a type prefix with 'typename' to indicate a type
>
> ^^^^^^^^^^^^^^^^^^^^^^
>
> You must use 'typename' for dependent types, the MSDN page for C4346
> explains that further, see msdn.microsoft.com.
>
> cheers
>
> Uli

Thanks for reply.. As I am a newbie I dont know where should i put
typename to get rid of errors

Re: Compile error:dependent name is not a type by armancho_x

armancho_x
Thu Dec 13 06:36:00 PST 2007

//An example:
template<class T>
class A
{
typename std::vector<T>::value_type m_t;
};

Because the compiler cannot [implicitly] deduce std::vector<T>::value_type
as a type, you should explicitly state it by putting the typename keword in
front of that type.



--
=====
Arman

An internal error has occured while showing an internal error!
-- eclipse


"sanil" wrote:

> On Dec 13, 6:30 pm, Ulrich Eckhardt <eckha...@satorlaser.com> wrote:
> > sanil wrote:
> >
> > [...]> template <class T>
> > > ParameterStringAW<T>::PKeyValuePair
> > > ParameterStringAW<T>::Exists( PCT szKey ) const
> > [...]
> > > warning C4346: 'ParameterStringAW<T>::PKeyValuePair' : dependent name
> > > is not a type prefix with 'typename' to indicate a type
> >
> > ^^^^^^^^^^^^^^^^^^^^^^
> >
> > You must use 'typename' for dependent types, the MSDN page for C4346
> > explains that further, see msdn.microsoft.com.
> >
> > cheers
> >
> > Uli
>
> Thanks for reply.. As I am a newbie I dont know where should i put
> typename to get rid of errors
>

Re: Compile error:dependent name is not a type by Ben

Ben
Thu Dec 13 07:30:39 PST 2007


"sanil" <saniltalathi@gmail.com> wrote in message
news:448a882f-0a6d-4dae-92b6-9dc03746884b@i29g2000prf.googlegroups.com...
> I'm getting a compile error on vs2005 that I dont understand. The
> help
> explains that this is a breaking change for VC++.NET 2005 compiler,
> made in
> order to conform to the ISO C++ standard, and I've tried it using evc+
> + 4.0 sp4 and
> it compiles ok.

Standard support in EVC++ is even worse than in VC++ 2005.