Date: Fri, 06 May 2022 10:24:32 +0100
Standardese:
https://timsong-cpp.github.io/cppwp/n4868/temp.inst#3
"The implicit instantiation of a class template specialization causes [...] the implicit instantiation of the declarations, **but not of the definitions**, of the non-deleted class member functions, [...] , **and friends**; and [...]"
On 6 May 2022 10:17:33 BST, "Lénárd Szolnoki via Std-Discussion" <std-discussion_at_[hidden]> wrote:
>Hi,
>
>Implicit instantiations of class templates don't instantiate the definitions of functions within the class. I don't think that friend functions are an exception.
>
>Cheers,
>Lénárd
>
>On 6 May 2022 09:46:11 BST, Yongwei Wu via Std-Discussion <std-discussion_at_[hidden]> wrote:
>>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/
https://timsong-cpp.github.io/cppwp/n4868/temp.inst#3
"The implicit instantiation of a class template specialization causes [...] the implicit instantiation of the declarations, **but not of the definitions**, of the non-deleted class member functions, [...] , **and friends**; and [...]"
On 6 May 2022 10:17:33 BST, "Lénárd Szolnoki via Std-Discussion" <std-discussion_at_[hidden]> wrote:
>Hi,
>
>Implicit instantiations of class templates don't instantiate the definitions of functions within the class. I don't think that friend functions are an exception.
>
>Cheers,
>Lénárd
>
>On 6 May 2022 09:46:11 BST, Yongwei Wu via Std-Discussion <std-discussion_at_[hidden]> wrote:
>>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 09:24:36