C++ Logo

std-discussion

Advanced search

Re: Templated entity: non-template friend function

From: Yongwei Wu <wuyongwei_at_[hidden]>
Date: Fri, 6 May 2022 16:46:11 +0800
Sorry, I think I misunderstood your problem in my last email. It is not
really about friends (though it can cause troubles), but the instantiation
moment. David pinned it: the function would be available as long as you
instantiate S::X<256>.

On Thu, 5 May 2022 at 17:28, Vladimir Grigoriev via Std-Discussion <
std-discussion_at_[hidden]> wrote:

> Try this code
>
> https://gcc.godbolt.org/z/Mrb3WzMv7
>
> If to write
>
> inline X<256> operator+(const X<256>&, const X<256>&) noexcept;
>
> then the error message is
>
> <source>:24: undefined reference to `S::operator+(S::X<256u> const&,
> S::X<256u> const&)'
>
>
>
>
> You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or
> http://ru.stackoverflow.com
>

-- 
Yongwei Wu
URL: http://wyw.dcweb.cn/

Received on 2022-05-06 08:46:18