Interface Copy Policy in dotnet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My collection need to upgrade to dotnet. It is right in vc6, but is error in
vc7.net

following is code:
template <class ContainerType, class InterfaceType>
class InterfaceCopy
{
public :
typedef ContainerType::value_type SourceType;

static void init(InterfaceType** p)
{
_CopyInterface<InterfaceType>::init(p);
}

static void destroy(InterfaceType** p)
{
_CopyInterface<InterfaceType>::destroy(p);
}

static HRESULT copy(InterfaceType** pTo, SourceType* pFrom)
{
return _CopyInterface<InterfaceType>::copy(pTo, (&(pFrom->second)));
}

}; // class Interface Copy Policy

Change
typedef ContainerType::value_type SourceType;
to
typename ContainerType::value_type SourceType;

f:\VideoMonitor.ZHP\VideoSampleDevice\VideoSampleDevices.h(28) : error
C2061: syntax error: identifier ¡°SourceType¡±
.....................

Thanks.

zhp80.Townee
 
Hi zhp80.Townee,
typename ContainerType::value_type SourceType;

f:\VideoMonitor.ZHP\VideoSampleDevice\VideoSampleDevices.h(28) : error
C2061: syntax error: identifier ¡°SourceType¡±

I don't think typename is legal here... Or it is, but it makes SourceType an instance of ContainerType::value_type. See
http://msdn.com/library/en-us/vclang/html/_langref_typename.asp

Of course, I'm no language expert, so it could be that I'm overlooking something, but I'd change it to a typedef if I were you.
 
My collection need to upgrade to dotnet. It is right in vc6, but is error in
vc7.net

following is code:
template <class ContainerType, class InterfaceType>
class InterfaceCopy
{
public :
typedef ContainerType::value_type SourceType;

static void init(InterfaceType** p)
{
_CopyInterface<InterfaceType>::init(p);
}

static void destroy(InterfaceType** p)
{
_CopyInterface<InterfaceType>::destroy(p);
}

static HRESULT copy(InterfaceType** pTo, SourceType* pFrom)
{
return _CopyInterface<InterfaceType>::copy(pTo, (&(pFrom->second)));
}

}; // class Interface Copy Policy

Change
typedef ContainerType::value_type SourceType;
to
typename ContainerType::value_type SourceType;

Use typedef typename ContainerType::value_type SourceType;

You're still defining a typedef (SourceType), but the definition of
this typedef is a dependent type, and therefore the compiler needs to
be told that ContainerType::value_type is a type.

Arnaud
MVP - VC
 
Back
Top