开发者

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

开发者 https://www.devze.com 2023-04-11 09:49 出处:网络
I write template declaration in *.hpp file and their \"definition\" in *.inl file linked from *.hpp just like this:

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?


Here's your definition:

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号