Topic: Definition of a template function explicit specialization
Author: Biju Thomas <b.thomas@acm.org>
Date: 2000/01/23 Raw View
Valentin Bonnard wrote:
>
> Is it allowed to define a template function explicit specialization
> in a friend declaration which has not been previously declared outside
> the class, as in the following ?
>
> template <typename> void foo();
> // at this point, no specializations of foo have been declared
>
> struct bar {
> template<> friend void foo<int> () {} // this is a _definition_
> };
>
> (g++ rejects it)
>
No. According to 14.7.3/20:
<quote>
An explicit specialization declaration shall not be a friend
declaration.
</quote>
--
Biju Thomas
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Valentin Bonnard <Bonnard.V@wanadoo.fr>
Date: 2000/01/19 Raw View
Happy new year everyone !
My first question this year is about explicit specialization.
Is it allowed to define a template function explicit specialization
in a friend declaration which has not been previously declared outside
the class, as in the following ?
template <typename> void foo();
// at this point, no specializations of foo have been declared
struct bar {
template<> friend void foo<int> () {} // this is a _definition_
};
(g++ rejects it)
--
Valentin Bonnard
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]