template <class _DataType, class _InterType>
class CnKeyFramePath : public CnPathProducer<_DataType>
{
//FUNCTIONS
public:
//base object style of constructor & destructor
CnKeyFramePath() {m_bOk=false;}
virtual ~CnKeyFramePath() { End(); }
//a must to call if you want to use the object
virtual bool Init(std::list< _DataType >& oKeys, _InterType < _DataType >* pInterpolator, float fKeyTime);
the compiler claims about this part:
_InterType < _DataType >* pInterpolator in the init call, why can´t I do this?.
Thnaks in advance,
HexDump.
Templates, why can´t I do this?
Hello,
Here is part of the class I want to create:
how is the compiler supposed to know _InterType is itself a template?
"That''s not a bug, it''s a feature!"
--me
"That''s not a bug, it''s a feature!"
--me
You're meant to do something like this:
If your compiler doesn't support it, you'll have to find a work around or use a better compiler. Edit: can't spell.
[edited by - Null and Void on March 24, 2004 7:01:30 PM]
template <typename _DataType, template <typename> class _InterType>class CnKeyFramePath : public CnPathProducer<_DataType>{ //FUNCTIONS public: //base object style of constructor & destructor CnKeyFramePath() {m_bOk=false;} virtual ~CnKeyFramePath() { End(); } //a must to call if you want to use the object virtual bool Init(std::list< _DataType >& oKeys, _InterType < _DataType >* pInterpolator, float fKeyTime);
If your compiler doesn't support it, you'll have to find a work around or use a better compiler. Edit: can't spell.
[edited by - Null and Void on March 24, 2004 7:01:30 PM]
actually, what you want to do IS possible .. if your arguments are right .. the first response is totally incorrect (a template doesn''t KNOW anything, it just tries to compile and if it can with the arguments given, it does).
Here''s a simple example that works
so i don''t know what your error is, but it isn''t the template stuff ... UNLESS _InterType isn''t a templated type.
Here''s a simple example that works
template <typename ContainerType, typename ElementTypeclass MyClass : ContainerType<ElementType> { private: ElementType prototypeElement; public: void SomeFunction(ContainerType<ElementType> &container); void SomeFunction(MyClass &container); };
so i don''t know what your error is, but it isn''t the template stuff ... UNLESS _InterType isn''t a templated type.
yes, but his operation demands that _InterType be a templated type... therefore, Null and Voids solution is the logical one.
The only extra piece of information is in the template argument list:
template< typename _DataType, template class _InterType >
which is basically specifying that Intertype can be any templated class. Now, upond initialization (when you actually instantiate CnKeyFramePath< T,L >), the compiler will only validate the statement if L is a templated type.
[edited by - psamty10 on March 24, 2004 7:22:02 PM]
The only extra piece of information is in the template argument list:
template< typename _DataType, template class _InterType >
which is basically specifying that Intertype can be any templated class. Now, upond initialization (when you actually instantiate CnKeyFramePath< T,L >), the compiler will only validate the statement if L is a templated type.
[edited by - psamty10 on March 24, 2004 7:22:02 PM]
Will also depend on the compiler your using, not all of them have full template support, i.e. they don''t comply with the spec (VC 6.0 is an example).
Well, I´m a bit messed up, I tried your solutions but no one worked for me. I suppose it will be a Vc++ 6.0 prob, that do not support this kind of declarations (it complains that I can´t nest templates).
HexDump
[edited by - HexDump on March 25, 2004 1:40:38 AM]
HexDump
[edited by - HexDump on March 25, 2004 1:40:38 AM]
quote:Original post by HexDumpWhen you get a compiler error you think may be because of the compiler''s crappiness, try it out in GCC. It''s free after all, and you just need to test this specific part. Get Dev-C++ for ez installation.
Well, I´m a bit messed up, I tried your solutions but no one worked for me. I suppose it will be a Vc++ 6.0 prob, that do not support this kind of declarations (it complains that I can´t nest templates).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement