How to define template function within template class in *.inl file

守給你的承諾、 提交于 2019-11-26 20:14:06

问题


I write template declaration in *.hpp file and their "definition" in *.inl file linked from *.hpp

just like this:

//*.hpp
template <typename T1, typename T2>
class SomeClass
{
public:
    void someMethod();
};

//*.inl
template <typename T1, typename T2>
void SomeClass<T1, T2>::someMethod()
{
}

but how to write extra templated method inside template class in *.inl file?

//*.hpp
template <typename T1, typename T2>
class SomeClass
{
public:
    void someMethod();

    template <typename E>
    void extraTypedMethod(E & e);
};

//*.inl
template <typename T1, typename T2>
void SomeClass<T1, T2>::someMethod()
{
}

//how can I here define extraTypedmethod?

回答1:


Here's your definition:

template <typename T1, typename T2>
template <typename E>
void SomeClass<T1, T2>::extraTypedMethod(E & e)
{
}


来源:https://stackoverflow.com/questions/7659322/how-to-define-template-function-within-template-class-in-inl-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!