You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3484dae
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/cpp/partial-ordering-of-function-templates-cpp.md
+6-7Lines changed: 6 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,14 @@
1
1
---
2
2
title: "Partial Ordering of Function Templates (C++)"
3
-
ms.date: "11/04/2016"
3
+
ms.date: "07/30/2019"
4
4
helpviewer_keywords: ["partial ordering of function templates"]
5
5
ms.assetid: 0c17347d-0e80-47ad-b5ac-046462d9dc73
6
6
---
7
7
# Partial Ordering of Function Templates (C++)
8
8
9
9
Multiple function templates that match the argument list of a function call can be available. C++ defines a partial ordering of function templates to specify which function should be called. The ordering is partial because there can be some templates that are considered equally specialized.
10
10
11
-
The compiler chooses the most specialized template function available from the possible matches. For example, if a function template takes a type __T__, and another function template taking __T\*__ is available, the __T\*__ version is said to be more specialized and is preferred over the generic __T__ version whenever the argument is a pointer type, even though both would be allowable matches.
11
+
The compiler chooses the most specialized template function available from the possible matches. For example, if a function template takes a type `T` and another function template that takes `T*` is available, the `T*` version is said to be more specialized. It's preferred over the generic `T` version whenever the argument is a pointer type, even though both would be allowable matches.
12
12
13
13
Use the following process to determine if one function template candidate is more specialized:
14
14
@@ -20,17 +20,17 @@ Use the following process to determine if one function template candidate is mor
20
20
21
21
1. Repeat the same process with T1 and T2 reversed.
22
22
23
-
1. If one template is a valid template argument list for the other template, but the converse is not true, then that template is considered to be less specialized than the other template. If both templates using the previous stepform valid arguments for each other, then they are considered to be equally specialized, and an ambiguous call results when you attempt to use them.
23
+
1. If one template is a valid template argument list for the other template, but the converse isn't true, then that template is considered to be less specialized than the other template. If by using the previous step, both templates form valid arguments for each other, then they're considered to be equally specialized, and an ambiguous call results when you attempt to use them.
24
24
25
25
1. Using these rules:
26
26
27
27
1. A template specialization for a specific type is more specialized than one taking a generic type argument.
28
28
29
-
1. A template taking only __T\*__ is more specialized than one taking only __T__, because a hypothetical type __X\*__ is a valid argument for a __T__ template argument, but __X__ is not a valid argument for a __T\*__ template argument.
29
+
1. A template taking only `T*` is more specialized than one taking only `T`, because a hypothetical type `X*` is a valid argument for a `T` template argument, but `X` is not a valid argument for a `T*` template argument.
30
30
31
-
1.__const T__ is more specialized than __T__, because __const X__ is a valid argument for a __T__ template argument, but __X__ is not a valid argument for a __const T__ template argument.
31
+
1.`const T` is more specialized than `T`, because `const X` is a valid argument for a `T` template argument, but `X` is not a valid argument for a `const T` template argument.
32
32
33
-
1.__const T\*__ is more specialized than __T\*__, because __const X\*__ is a valid argument for a __T\*__ template argument, but __X\*__ is not a valid argument for a __const T\*__ template argument.
33
+
1.`const T*` is more specialized than `T*`, because `const X*` is a valid argument for a `T*` template argument, but `X*` is not a valid argument for a `const T*` template argument.
34
34
35
35
## Example
36
36
@@ -41,7 +41,6 @@ The following sample works as specified in the standard:
0 commit comments