help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gsl] Re: Reg :: Error in declaring typedef of template class


From: Akanksh Vashisth
Subject: Re: [Help-gsl] Re: Reg :: Error in declaring typedef of template class
Date: Wed, 11 Nov 2009 08:56:30 +0000

Hello Sumit,

In C++ typedef of a template is illegal, so the following code

template < class T >
typedef  m_signal_inout_if < T >  m_signal_out_if < T > ;

will not compile.

If you do want to typedef something like this, you need to surround it with
a class definition, such as:

template<typename T>
struct m_signal_out_if
{
    typedef m_signal_inout_if  < T > type;
}

This can now be used as a type in the following way:

m_signal_out_if<SomeType>::type variable_name;

But seeing that the difference in you typedef name and the original class
name is not a lot, the overhead and complexity of this typedef is (in my
opinion) not acceptable.

Hope this helps.

Akanksh Vashisth
Graphics Engine Programmer
ArtVPS Ltd.
Cambridge, UK

2009/11/11 Sumit Adhikari <address@hidden>

> A little correction :
>
> # ifndef M_SIGNAL_OUT_IF_H_
> # define M_SIGNAL_OUT_IF_H_
>
>
> # include "m_signal_inout_if.h"
>
> template < class T > typedef  m_signal_inout_if < T >  m_signal_out_if < T
> > ;
>
>
>
> # endif /*M_SIGNAL_OUT_IF_H_*/
>
>
>
> --------------------------------------------
> Sumit Adhikari
> System Design Engineer
> austriamicrosystems AG
> Business Unit : Automotive
> Mob : 00-91-9885271710/00-91-9000161710
>
>
>
> On 11/11/2009 8:49 AM, Sumit Adhikari wrote:
>
>> Hello All,
>>
>> I have a template class like as follows :
>>
>> # ifndef M_SIGNAL_INOUT_IF_H_
>> # define M_SIGNAL_INOUT_IF_H_
>>
>> # include "m_signal_in_if.h"
>>
>> template < class T > class m_signal_inout_if : public m_signal_in_if < T >
>> {
>>   public :
>>      virtual void write (const T&) = 0 ;
>>      virtual void initialize(const T&) = 0;
>> };
>>
>>
>> # endif /*M_SIGNAL_INOUT_IF_H_*/
>>
>> I want to declare typedef of m_signal_inout_if and I have done it as
>> follows :
>>
>> # ifndef M_SIGNAL_OUT_IF_H_
>> # define M_SIGNAL_OUT_IF_H_
>>
>>
>> # include "m_signal_inout_if.h"
>>
>> template < class T > m_signal_inout_if < T >  m_signal_out_if < T > ;
>>
>>
>> # endif /*M_SIGNAL_OUT_IF_H_*/
>>
>>
>> But I am getting syntax error in this process.
>> Can anybody please tell me what is the wrong with it ?
>> Regards,
>>
>>
>
> _______________________________________________
> Help-gsl mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-gsl
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]