C++ Logo

std-discussion

Advanced search

Re: nodeclspec-function-declaration

From: Russell Shaw <rjshaw_at_[hidden]>
Date: Thu, 4 Apr 2024 21:42:40 +1100
On 3/4/24 23:55, Andrew Schepler wrote:
> > What would an example be of a nodeclspec-function-declaration used in a
> template-declaration ?
>
> template <typename T> C<T>::C();
>
> The point of nodeclspec-function-declaration is to allow non-definition function
> declarations that don't have a syntactic return type in these
> template-related contexts.
...

Thankyou Andrew.S

I mistakenly did 'template <typename T> C<T>::C {};' and got mislead.

However, i still get an error (gnu c++ -std=c++20):

-----------------------------

template<typename T> struct C {
     C();
};

template<typename T> C<T>::C(); <-- error: declaration of ‘C<T>::C()’ outside
of class is not definition [-fpermissive]

-----------------------------

Received on 2024-04-04 10:42:44