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

45 lines
1.6 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.

[over.pre]
# 12 Overloading [[over]](./#over)
## 12.1 Preamble [over.pre]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/overloading.tex#L9)
[*Note [1](#note-1)*:
Each of two or more entities with the same name in the same scope,
which must be functions or function templates,
is commonly called an “overload”[.](#1.sentence-1)
— *end note*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/overloading.tex#L18)
When a function is designated in a call, which function
declaration is being referenced and the validity of the call
are determined by comparing the types
of the arguments at the point of use with the types of the parameters
in the declarations in the overload set[.](#2.sentence-1)
This function selection process is called[*overload resolution*](#def:overload_resolution "12.1Preamble[over.pre]") and is defined in [[over.match]](over.match "12.2Overload resolution")[.](#2.sentence-2)
[*Note [2](#note-2)*:
Overload sets are formed by [*id-expression*](expr.prim.id.general#nt:id-expression "7.5.5.1General[expr.prim.id.general]")*s* naming functions and function templates and
by [*splice-expression*](expr.prim.splice#nt:splice-expression "7.5.9Expression splicing[expr.prim.splice]")*s* designating entities of the same kinds[.](#2.sentence-3)
— *end note*]
[*Example [1](#example-1)*:
[🔗](#:overloading,example_of)
double abs(double);int abs(int);
abs(1); // calls abs(int); abs(1.0); // calls abs(double); — *end example*]