From Jason Turner

[temp.fct.spec.general]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp20eu2505/{from.md → to.md} +31 -0
tmp/tmp20eu2505/{from.md → to.md} RENAMED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### General <a id="temp.fct.spec.general">[[temp.fct.spec.general]]</a>
2
+
3
+ A function instantiated from a function template is called a function
4
+ template specialization; so is an explicit specialization of a function
5
+ template. Template arguments can be explicitly specified when naming the
6
+ function template specialization, deduced from the context (e.g.,
7
+ deduced from the function arguments in a call to the function template
8
+ specialization, see  [[temp.deduct]]), or obtained from default template
9
+ arguments.
10
+
11
+ Each function template specialization instantiated from a template has
12
+ its own copy of any static variable.
13
+
14
+ [*Example 1*:
15
+
16
+ ``` cpp
17
+ template<class T> void f(T* p) {
18
+ static T s;
19
+ };
20
+
21
+ void g(int a, char* b) {
22
+ f(&a); // calls f<int>(int*)
23
+ f(&b); // calls f<char*>(char**)
24
+ }
25
+ ```
26
+
27
+ Here `f<int>(int*)` has a static variable `s` of type `int` and
28
+ `f<char*>(char**)` has a static variable `s` of type `char*`.
29
+
30
+ — *end example*]
31
+