On Dec 8, 7:38 pm, peter koch <peter.koch.lar...@gmail.com> wrote:
> On 8 Dec., 17:52, zr <zvir...@gmail.com> wrote:
>
>
>
> > Hi,
>
> > My original intent was to use the following code:
>
> > template <typename T> // compilation error: at typedef template is
> > illegal
> > typedef (*FunctionType)(T*,T const*,T const*,T const*,T const*, int
> > const*);
>
> > template <typename T, FunctionType f>
> > class foo
> > {
> > ...
>
> > }
>
> > but the compiler complained about no templated typedef allowed.
>
> > Instead i am using the following not so aesthetic code:
> > template <typename T, (*f)(T*,T const*,T const*,T const*,T const*, int
> > const*)>
> > class foo
> > {
> > ...
>
> > }
>
> > Now each class that inherits from foo will have this horrific template
> > declaration.
> > Is there any better way to do this?
>
> You could use
>
> template< typename T >
> struct func
> {
> typedef void (*ttype)(T const*); // or whatever
>
> };
>
> and then use func<T>::ttype instead of the typedef.
>
> /Peter
Peter, thank you.