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 09:07:14 +0000

Also, if a collection of such typedefs is needed, something like this can be
done ( but I would not suggest it as a default solution )

template<typename T>
struct MyType
{
     typedef  m_signal_inout_if < T >  m_signal_out_if;
     typedef something_else_01<T> something_01;
     typedef something_else_02<T> something_02;
}

and these can now be used as:

MyType<SomeType1>:: m_signal_out_if variable_name_01;
MyType<SomeType2>:: something_01   variable_name_02;
MyType<SomeType3>:: something_02   variable_name_03;

Hope this helps.

Akanksh Vashisth
Graphics Engine Programmer
ArtVPS Ltd.
Cambridge, UK

2009/11/11 Akanksh Vashisth <address@hidden>

> 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]