Files
2025-10-25 03:02:53 +03:00

50 lines
2.0 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[temp.fct.general]
# 13 Templates [[temp]](./#temp)
## 13.7 Template declarations [[temp.decls]](temp.decls#temp.fct.general)
### 13.7.7 Function templates [[temp.fct]](temp.fct#general)
#### 13.7.7.1 General [temp.fct.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L4052)
A function template defines an unbounded set of related functions[.](#1.sentence-1)
[*Example [1](#example-1)*:
A family of sort functions can be declared like this:template<class T> class Array { };template<class T> void sort(Array<T>&);
— *end example*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L4062)
[*Note [1](#note-1)*:
A function template can have the same name as other function templates
and non-template functions ([[dcl.fct]](dcl.fct "9.3.4.6Functions")) in the same scope[.](#2.sentence-1)
— *end note*]
A non-template function is not
related to a function template
(i.e., it is never considered to be a specialization),
even if it has the same name and type
as a potentially generated function template specialization[.](#2.sentence-2)[115](#footnote-115 "That is, declarations of non-template functions do not merely guide overload resolution of function template specializations with the same name. If such a non-template function is odr-used ([term.odr.use]) in a program, it must be defined; it will not be implicitly instantiated using the function template definition.")
[115)](#footnote-115)[115)](#footnoteref-115)
That is,
declarations of non-template functions do not merely guide
overload resolution of
function template specializations
with the same name[.](#footnote-115.sentence-1)
If such a non-template function is odr-used ([[basic.def.odr]](basic.def.odr#term.odr.use "6.3One-definition rule")) in a program, it must be defined;
it will not be implicitly instantiated using the function template definition[.](#footnote-115.sentence-2)