B
Bronek Kozicki
Visual Studio .NET 2003 is refusing to compile following code:
#include <cstdio>
namespace
{
struct Functor
{
template <typename X>
void operator() (X* px)
{
delete px;
}
};
Functor f;
}
template <typename T, T* pf>
struct del_functor_adaptor
{
template <typename X>
static void free(X* px, void (T::*)(X *) = &T:perator() )
{
pf->operator() (px);
}
};
int main()
{
int* a = new int;
del_functor_adaptor<Functor, &f>::free(a);
}
It reports error:
C:\DATA\USERS\bronislaw\My Documents\msys\T147.cpp(22) : error C2059:
syntax error : ')'
C:\DATA\USERS\bronislaw\My Documents\msys\T147.cpp(26) : see
reference to class template instantiation 'del_functor_adaptor<T,pf>'
being compiled
C:\DATA\USERS\bronislaw\My Documents\msys\T147.cpp(22) : error C2143:
syntax error : missing ')' before '<end Parse>'
C:\DATA\USERS\bronislaw\My Documents\msys\T147.cpp(22) : error C2059:
syntax error : ')'
C:\DATA\USERS\bronislaw\My Documents\msys\T147.cpp(35) : see
reference to class template instantiation 'del_functor_adaptor<T,pf>'
being compiled
with
[
T=`anonymous-namespace'::Functor,
pf=& `anonymous-namespace'::f
]
C:\DATA\USERS\bronislaw\My Documents\msys\T147.cpp(22) : error C2143:
syntax error : missing ')' before '<end Parse>'
C:\DATA\USERS\bronislaw\My Documents\msys\T147.cpp(35) : error C2780:
'void del_functor_adaptor<T,pf>::free(X *,void
(`anonymous-namespace'::Functor::* )(X *))' : expects 2 arguments - 1
provided
with
[
T=`anonymous-namespace'::Functor,
pf=& `anonymous-namespace'::f
]
C:\DATA\USERS\bronislaw\My Documents\msys\T147.cpp(22) : see
declaration of 'del_functor_adaptor<T,pf>::free'
with
[
T=`anonymous-namespace'::Functor,
pf=& `anonymous-namespace'::f
]
#include <cstdio>
namespace
{
struct Functor
{
template <typename X>
void operator() (X* px)
{
delete px;
}
};
Functor f;
}
template <typename T, T* pf>
struct del_functor_adaptor
{
template <typename X>
static void free(X* px, void (T::*)(X *) = &T:perator() )
{
pf->operator() (px);
}
};
int main()
{
int* a = new int;
del_functor_adaptor<Functor, &f>::free(a);
}
It reports error:
C:\DATA\USERS\bronislaw\My Documents\msys\T147.cpp(22) : error C2059:
syntax error : ')'
C:\DATA\USERS\bronislaw\My Documents\msys\T147.cpp(26) : see
reference to class template instantiation 'del_functor_adaptor<T,pf>'
being compiled
C:\DATA\USERS\bronislaw\My Documents\msys\T147.cpp(22) : error C2143:
syntax error : missing ')' before '<end Parse>'
C:\DATA\USERS\bronislaw\My Documents\msys\T147.cpp(22) : error C2059:
syntax error : ')'
C:\DATA\USERS\bronislaw\My Documents\msys\T147.cpp(35) : see
reference to class template instantiation 'del_functor_adaptor<T,pf>'
being compiled
with
[
T=`anonymous-namespace'::Functor,
pf=& `anonymous-namespace'::f
]
C:\DATA\USERS\bronislaw\My Documents\msys\T147.cpp(22) : error C2143:
syntax error : missing ')' before '<end Parse>'
C:\DATA\USERS\bronislaw\My Documents\msys\T147.cpp(35) : error C2780:
'void del_functor_adaptor<T,pf>::free(X *,void
(`anonymous-namespace'::Functor::* )(X *))' : expects 2 arguments - 1
provided
with
[
T=`anonymous-namespace'::Functor,
pf=& `anonymous-namespace'::f
]
C:\DATA\USERS\bronislaw\My Documents\msys\T147.cpp(22) : see
declaration of 'del_functor_adaptor<T,pf>::free'
with
[
T=`anonymous-namespace'::Functor,
pf=& `anonymous-namespace'::f
]