Files
cppdraft_translate/cppdraft/freestanding/item.md
2025-10-25 03:02:53 +03:00

160 lines
5.6 KiB
Markdown
Raw 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.

[freestanding.item]
# 16 Library introduction [[library]](./#library)
## 16.3 Method of description [[description]](description#freestanding.item)
### 16.3.3 Other conventions [[conventions]](conventions#freestanding.item)
#### 16.3.3.7 Freestanding items [freestanding.item]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L968)
A [*freestanding item*](#def:freestanding_item "16.3.3.7Freestanding items[freestanding.item]") is
a declaration, entity, [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4The typedef specifier[dcl.typedef]"), or macro
that is required to be present in
a freestanding implementation and a hosted implementation[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L975)
Unless otherwise specified,
the requirements on freestanding items for a freestanding implementation
are the same as the corresponding requirements for a hosted implementation,
except that not all of the members of those items are required to be present[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L981)
Function declarations and function template declarations
followed by a comment that include *freestanding-deleted* are[*freestanding deleted functions*](#def:function,freestanding_deleted "16.3.3.7Freestanding items[freestanding.item]")[.](#3.sentence-1)
On freestanding implementations,
it is implementation-defined
whether each entity introduced by a freestanding deleted function
is a deleted function ([[dcl.fct.def.delete]](dcl.fct.def.delete "9.6.3Deleted definitions")) or
whether the requirements are the same as
the corresponding requirements for a hosted implementation[.](#3.sentence-2)
[*Note [1](#note-1)*:
Deleted definitions reduce the chance of overload resolution silently changing
when migrating from a freestanding implementation to a hosted implementation[.](#3.sentence-3)
— *end note*]
[*Example [1](#example-1)*: double abs(double j); // freestanding-deleted — *end example*]
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L1001)
A declaration in a synopsis is a freestanding item if
- [(4.1)](#4.1)
it is followed by a comment that includes *freestanding*,
- [(4.2)](#4.2)
it is followed by a comment that includes *freestanding-deleted*, or
- [(4.3)](#4.3)
the header synopsis begins with a comment
that includes *freestanding* and
the declaration is not followed by a comment that includes *hosted*[.](#4.sentence-1)
[*Note [2](#note-2)*:
Declarations followed by *hosted* in freestanding headers are
not freestanding items[.](#4.3.sentence-2)
As a result, looking up the name of such functions can vary
between hosted and freestanding implementations[.](#4.3.sentence-3)
— *end note*]
[*Example [2](#example-2)*: // all freestandingnamespace std { — *end example*]
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L1024)
An entity, deduction guide, or [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4The typedef specifier[dcl.typedef]") is a freestanding item if its introducing declaration is not followed by
a comment that includes *hosted*, and is:
- [(5.1)](#5.1)
introduced by a declaration that is a freestanding item,
- [(5.2)](#5.2)
a member of a freestanding item other than a namespace,
- [(5.3)](#5.3)
an enumerator of a freestanding item,
- [(5.4)](#5.4)
a deduction guide of a freestanding item,
- [(5.5)](#5.5)
an enclosing namespace of a freestanding item,
- [(5.6)](#5.6)
a friend of a freestanding item,
- [(5.7)](#5.7)
denoted by a [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4The typedef specifier[dcl.typedef]") that is a freestanding item, or
- [(5.8)](#5.8)
denoted by an alias template that is a freestanding item[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L1042)
A macro is a freestanding item if it is defined in a header synopsis and
- [(6.1)](#6.1)
the definition is followed by a comment
that includes *freestanding*, or
- [(6.2)](#6.2)
the header synopsis begins with a comment
that includes *freestanding* and
the definition is not followed by a comment that includes *hosted*[.](#6.sentence-1)
[*Example [3](#example-3)*: #define NULL *see below* // freestanding — *end example*]
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L1058)
[*Note [3](#note-3)*:
Freestanding annotations follow some additional exposition conventions
that do not impose any additional normative requirements[.](#7.sentence-1)
Header synopses that begin with a comment containing "all freestanding"
contain no hosted items and no freestanding deleted functions[.](#7.sentence-2)
Header synopses that begin with a comment containing "mostly freestanding"
contain at least one hosted item or freestanding deleted function[.](#7.sentence-3)
Classes and class templates followed by a comment
containing "partially freestanding"
contain at least one hosted item or freestanding deleted function[.](#7.sentence-4)
— *end note*]
[*Example [4](#example-4)*: template<class T, size_t N> struct array; // partially freestandingtemplate<class T, size_t N>struct array {constexpr reference operator[](size_type n); constexpr const_reference operator[](size_type n) const; constexpr reference at(size_type n); // freestanding-deletedconstexpr const_reference at(size_type n) const; // freestanding-deleted}; — *end example*]