C++ Logo

std-discussion

Advanced search

Re: nodeclspec-function-declaration

From: Jens Maurer <jens.maurer_at_[hidden]>
Date: Thu, 25 Apr 2024 19:06:57 +0200
On 25/04/2024 15.33, Russell Shaw via Std-Discussion wrote:
> Hi,
>
> In 9.12 p164 General [dcl.dcl] 14882:2020(E) :
>
> ------------------
> 12
> A nodeclspec-function-declaration shall declare a constructor, destructor, or
> conversion function.
>
> [Note 3 : A nodeclspec-function-declaration can only be used in a
> template-declaration (13.1), explicit-instantiation (13.9.3),
> or explicit-specialization (13.9.4). — end note]
>
> ------------------
>
> I can get the 'explicit-instantiation' and 'explicit-specialization' to work,
> but how do i get the 'template-declaration' to work ?
>
> ++++++++++++++++++
>
> template<typename T> struct S {
> S();
> };
>
> template<> S<int>::S();
>
> template S<int>::S();
>
> template<typename T> S<T>::S(); <-- error: declaration of ‘S<T>::S()’
> outside of class is not definition [-fpermissive]

How about

struct S {
  template<class T> S(T);
};

?

Jens

Received on 2024-04-25 17:07:02