Files
cppdraft_translate/cppdraft/alg/c/library.md
2025-10-25 03:02:53 +03:00

50 lines
1.9 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.

[alg.c.library]
# 26 Algorithms library [[algorithms]](./#algorithms)
## 26.13 C library algorithms [alg.c.library]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14449)
[*Note [1](#note-1)*:
The header [<cstdlib>](cstdlib.syn#header:%3ccstdlib%3e "17.2.2Header <cstdlib> synopsis[cstdlib.syn]") declares the functions described in this subclause[.](#1.sentence-1)
— *end note*]
[🔗](#lib:bsearch)
`void* bsearch(const void* key, void* base, size_t nmemb, size_t size,
c-compare-pred* compar);
void* bsearch(const void* key, void* base, size_t nmemb, size_t size,
compare-pred* compar);
const void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
c-compare-pred* compar);
const void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
compare-pred* compar);
void qsort(void* base, size_t nmemb, size_t size, c-compare-pred* compar);
void qsort(void* base, size_t nmemb, size_t size, compare-pred* compar);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14471)
*Preconditions*: For qsort, the objects in the array pointed to by base are of trivially copyable type[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14476)
*Effects*: These functions have the semantics specified in the C standard library[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14480)
*Throws*: Any exception thrown by compar ([[res.on.exception.handling]](res.on.exception.handling "16.4.6.14Restrictions on exception handling"))[.](#4.sentence-1)
See also: ISO/IEC 9899:2024, 7.24.5