C++ Logo

std-discussion

Advanced search

Re: Fwd: Re: Rditorial changes relative to an example in the section 13.8.2 Explicit instantiation

From: Maris Razvan <razvyboy2004_at_[hidden]>
Date: Wed, 31 Jul 2019 15:23:56 +0300
I can't speak about whether it should be considered a standard defect,
but in my opinion I do not think it should.

On Wed, Jul 31, 2019 at 3:04 PM Vladimir Grigoriev via Std-Discussion
<std-discussion_at_[hidden]> wrote:
>
> Could it be considered as a standard defect because it 1) looks like a declaration without a definition and 2) confuses readers of the code?
>
> With best regards,
> Vlad from Moscow
>
> You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com
>
> -------- Пересылаемое сообщение --------
> От кого: Maris Razvan <razvyboy2004_at_[hidden]>
> Кому: std-discussion_at_[hidden]
> Копия: Vladimir Grigoriev <vlad.moscow_at_[hidden]>
> Дата: Среда, 31 июля 2019, 14:38 +03:00
> Тема: Re: [std-discussion] Rditorial changes relative to an example in the section 13.8.2 Explicit instantiation
>
> Hello,
>
> [temp.explicit] p. 4 states:
>
> "A declaration of a function template, a variable template, a
> member function or static data member of a class template, or a member
> function template of a class or class template shall precede an
> explicit instantiation of that entity. [...]"
>
> So a preceding declaration of the function template is necessary.
>
> Also, [temp.explicit] p. 7 states:
>
> "[...] Otherwise, for an explicit instantiation definition the
> definition of a function template, a variable template, a member
> function template, or a member function or static data member of a
> class template shall be present in every translation unit in which it
> is explicitly instantiated."
>
> From these two paragraphs it follows that a declaration of a member
> function of a class template is required to precede the explicit
> instantiation (declaration/definition). Furthermore, if it is an
> explicit instantiation definition, the definition of a member function
> of a class template is required to be present in the translation unit,
> however is it not necessary to precede the explicit instantiation
> definition.
>
> On Wed, Jul 31, 2019 at 1:34 PM Vladimir Grigoriev via Std-Discussion
> <std-discussion_at_[hidden]> wrote:
> >
> > In the paragraph #4 of the section 13.8.2 Explicit instantiation there is the following example
> >
> > template<class T> class Array { void mf(); };
> > template class Array<char>;
> > template void Array<int>::mf();
> >
> >
> > Should it be
> >
> > template<class T> class Array { void mf(); };
> > template class Array<char>;
> > extern template void Array<int>::mf();
> >
> > because there is no definition of the member function mf.
> >
> > With best regards,
> > Vlad from Moscow
> >
> > You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com
> > --
> > Std-Discussion mailing list
> > Std-Discussion_at_[hidden]
> > http://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>
> ________________________________
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> http://lists.isocpp.org/mailman/listinfo.cgi/std-discussion

Received on 2019-07-31 07:26:05