This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
static function pointers in C++ template class
- From: "Wesley Smith" <wesley dot hoke at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Sat, 17 Feb 2007 16:18:40 -0800
- Subject: static function pointers in C++ template class
Hi,
I'm trying to figure out the proper syntax for setting static member
variables of a C++ template class that are function pointers. The
warnings from gcc don't really give any insight and a search of the
web turns up things that are close but not quite what I'm looking for.
Here's the code:
template <class T>
class udata
{
public:
//stuff
protected:
static void (*kill_func)(T); //my function pointer
};
//create specializations as well a general case
template <class T>
void (udata<T>::*kill_func)(T) = free;
template <dWorldID>
void (udata<dWorldID>::*kill_func)(dWorldID) = dWorldDestroy;
template <dSpaceID>
void (udata<dSpaceID>::*kill_func)(dSpaceID) = dSpaceDestroy;
The errors I'm getting are:
/Users/wesleysmith/jit.gl.lua_beta1/Lua_dev/ODE_Package/lua_ode_udata.h:62:
error: template declaration of 'void (udata<T>::* kill_func)(T)'
/Users/wesleysmith/jit.gl.lua_beta1/Lua_dev/ODE_Package/lua_ode_udata.h:65:
error: template declaration of 'void (udata<dxWorld*>::*
kill_func)(dxWorld*)'
/Users/wesleysmith/jit.gl.lua_beta1/Lua_dev/ODE_Package/lua_ode_udata.h:68:
error: template declaration of 'void (udata<dxSpace*>::*
kill_func)(dxSpace*)'
where dxSpace* is the same as dSpaceID and dxWorld* is the same as dWorldID
Where is my syntax going wrong?
thanks,
wes