<!DOCTYPE html><html lang='en'><head><title>[alg.c.library]</title><meta charset='UTF-8'/><link rel='stylesheet' type='text/css' href='14882.css'/><link rel='stylesheet' type='text/css' href='expanded.css' title='Notes and examples expanded'/><link rel='alternate stylesheet' type='text/css' href='colored.css' title='Notes and examples colored'/><link rel='alternate stylesheet' type='text/css' href='collapsed.css' title='Notes and examples collapsed'/><link rel='icon' href='icon.png'/></head><body><div class='wrapper'><h1 ><a class='secnum' style='min-width:73pt'>24</a> Algorithms library <a class='abbr_ref' href='./#algorithms'>[algorithms]</a></h1><h2 ><a class='secnum' style='min-width:88pt'>24.10</a> C library algorithms <a class='abbr_ref'>[alg.c.library]</a></h2><div class='para' id='1'><div class='marginalizedparent'><a class='marginalized' href='#1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/Eelis/draft73ca144c7e48612fe72742f9f6a5ec9ad6a934d2/source/algorithms.tex#L9780'>#</a></div><span class='indexparent'><a class='index' id=':<cstdlib>'></a></span><div id='1.note-1' class='note'>[<span style='white-space:nowrap'> </span><a class='note_link' href='#1.note-1'><span class='textit'>Note</span></a><div class='noteBody'><span class='textit'>:</span> <div id='1.sentence-1' class='sentence'>The header <a href='cstdlib.syn'><span class='texttt'>&lt;cstdlib&gt;</span></a>
declares the functions described in this subclause<a class='hidden_link' href='#1.sentence-1'>.</a></div> —<span style='white-space:nowrap'> </span><i>end note</i></div><span style='white-space:nowrap'> </span>]</div> <span class='indexparent'><a class='index' id='lib:bsearch'></a></span><span class='indexparent'><a class='index' id='lib:qsort'></a></span></div><div class='itemdecl' id='itemdecl:1'><div class='marginalizedparent'><a class='itemDeclLink' href='#itemdecl:1'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>void</span><span class='operator'>*</span> bsearch<span class='parenthesis'>(</span><span class='keyword'>const</span> <span class='keyword'>void</span><span class='operator'>*</span> key, <span class='keyword'>const</span> <span class='keyword'>void</span><span class='operator'>*</span> base, size_t nmemb, size_t size,
              <span class='textit'>c-compare-pred</span><span class='operator'>*</span> compar<span class='parenthesis'>)</span>;
<span class='keyword'>void</span><span class='operator'>*</span> bsearch<span class='parenthesis'>(</span><span class='keyword'>const</span> <span class='keyword'>void</span><span class='operator'>*</span> key, <span class='keyword'>const</span> <span class='keyword'>void</span><span class='operator'>*</span> base, size_t nmemb, size_t size,
              <span class='textit'>compare-pred</span><span class='operator'>*</span> compar<span class='parenthesis'>)</span>;
<span class='keyword'>void</span> qsort<span class='parenthesis'>(</span><span class='keyword'>void</span><span class='operator'>*</span> base, size_t nmemb, size_t size, <span class='textit'>c-compare-pred</span><span class='operator'>*</span> compar<span class='parenthesis'>)</span>;
<span class='keyword'>void</span> qsort<span class='parenthesis'>(</span><span class='keyword'>void</span><span class='operator'>*</span> base, size_t nmemb, size_t size, <span class='textit'>compare-pred</span><span class='operator'>*</span> compar<span class='parenthesis'>)</span>;
</code></div><div class='itemdescr'></div><div class='para' id='2'><div class='marginalizedparent'><a class='marginalized' href='#2'>2</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/Eelis/draft73ca144c7e48612fe72742f9f6a5ec9ad6a934d2/source/algorithms.tex#L9799'>#</a></div><div id='2.sentence-1' class='sentence'><span class='textit'>Effects:</span> 
These functions have the semantics specified in the C standard library<a class='hidden_link' href='#2.sentence-1'>.</a></div></div></div><div class='para' id='3'><div class='marginalizedparent'><a class='marginalized' href='#3'>3</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/Eelis/draft73ca144c7e48612fe72742f9f6a5ec9ad6a934d2/source/algorithms.tex#L9803'>#</a></div><div id='3.sentence-1' class='sentence'><span class='textit'>Remarks:</span> 
The behavior is undefined
unless the objects in the array pointed to by <span class='texttt'>base</span> are of trivial type<a class='hidden_link' href='#3.sentence-1'>.</a></div></div></div><div class='para' id='4'><div class='marginalizedparent'><a class='marginalized' href='#4'>4</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/Eelis/draft73ca144c7e48612fe72742f9f6a5ec9ad6a934d2/source/algorithms.tex#L9808'>#</a></div><div id='4.sentence-1' class='sentence'><span class='textit'>Throws:</span> 
Any exception thrown by <span class='texttt'>compar<span class='parenthesis'>(</span><span class='parenthesis'>)</span></span> (<a href='res.on.exception.handling'>[res.on.exception.handling]</a>)<a class='hidden_link' href='#4.sentence-1'>.</a></div></div></div><div id='sentence-1' class='sentence'><span class='textsc'>See also:</span> 
ISO C 7.22.5<a class='hidden_link' href='#sentence-1'>.</a></div></div></body></html>