Skip to content

Commit 3484dae

Browse files
authored
Merge pull request MicrosoftDocs#2203 from corob-msft/cr-1355
Fix stray prototype in Partial ordering of templates
2 parents a5e5c52 + e37810a commit 3484dae

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

‎docs/cpp/partial-ordering-of-function-templates-cpp.md‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
22
title: "Partial Ordering of Function Templates (C++)"
3-
ms.date: "11/04/2016"
3+
ms.date: "07/30/2019"
44
helpviewer_keywords: ["partial ordering of function templates"]
55
ms.assetid: 0c17347d-0e80-47ad-b5ac-046462d9dc73
66
---
77
# Partial Ordering of Function Templates (C++)
88

99
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.
1010

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.
1212

1313
Use the following process to determine if one function template candidate is more specialized:
1414

@@ -20,17 +20,17 @@ Use the following process to determine if one function template candidate is mor
2020

2121
1. Repeat the same process with T1 and T2 reversed.
2222

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 step form 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.
2424

2525
1. Using these rules:
2626

2727
1. A template specialization for a specific type is more specialized than one taking a generic type argument.
2828

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.
3030

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.
3232

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.
3434

3535
## Example
3636

@@ -41,7 +41,6 @@ The following sample works as specified in the standard:
4141
// compile with: /EHsc
4242
#include <iostream>
4343

44-
extern "C" int printf(const char*,...);
4544
template <class T> void f(T) {
4645
printf_s("Less specialized function called\n");
4746
}

0 commit comments

Comments
 (0)