Topic: Template specialization with template type


Author: "ec" <emilio@stud.phys.ethz.ch>
Date: Fri, 2 Feb 2001 17:19:27 GMT
Raw View
hi,
is it possible to do a template specialization for template types?
it should look something like that:

template<class T>
class Test
{
    public:
        Test();
};

// specialization of the constructor
template<class R>
Test<complex<R> >::Test<complex<R> >()
{
....
}

thanks,
ec


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]





Author: kuehl@ramsen.informatik.uni-konstanz.de (Dietmar Kuehl)
Date: Fri, 2 Feb 2001 17:54:52 GMT
Raw View
Hi,
ec (emilio@stud.phys.ethz.ch) wrote:
: is it possible to do a template specialization for template types?

Yes. It is called "partial specialization".

: // specialization of the constructor
: template<class R>
: Test<complex<R> >::Test<complex<R> >()

Close:

  template <class R>
  Test<complex<R> >::Test() { ... }
--
<mailto:dietmar_kuehl@yahoo.com> <http://www.dietmar-kuehl.de/>
Phaidros eaSE - Easy Software Engineering: <http://www.phaidros.com/>

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]





Author: Gabor Greif <ggreif@lucent.com>
Date: Mon, 5 Feb 2001 17:13:50 GMT
Raw View
Dietmar Kuehl wrote:
>
> Hi,
> ec (emilio@stud.phys.ethz.ch) wrote:
> : is it possible to do a template specialization for template types?
>
> Yes. It is called "partial specialization".
>
> : // specialization of the constructor
> : template<class R>
> : Test<complex<R> >::Test<complex<R> >()
>
> Close:
>
>   template <class R>
>   Test<complex<R> >::Test() { ... }

And would this work too?

template <template <class R> outer>
Test<outer<int> >::Test() { ... }

Thanks,

 Gabor

> --
[sigs snipped]

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]