1 Star 0 Fork 0

mobangjack / memory

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
classfoonathan_1_1memory_1_1bad__allocation__size.html 18.11 KB
一键复制 编辑 原始数据 按行查看 历史
Jonathan Müller 提交于 2020-05-05 17:04 . Update documentation
<!-- HTML header for doxygen 1.8.16-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.18"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>memory: bad_allocation_size Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">memory
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div id="main-nav">
<ul class="sm sm-dox" id="main-menu">
<li><a href="index.html">Main Page</a></li>
<li><a href="md_doc_tutorial.html">Tutorial</a></li>
<li><a href="namespacefoonathan_1_1memory.html">Index</a></li>
<li><a href="files.html">Files</a></li>
</ul>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.18 -->
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="namespacefoonathan.html">foonathan</a></li><li class="navelem"><a class="el" href="namespacefoonathan_1_1memory.html">memory</a></li><li class="navelem"><a class="el" href="classfoonathan_1_1memory_1_1bad__allocation__size.html">bad_allocation_size</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#pub-types">Typedefs</a> &#124;
<a href="#pub-static-methods">Static Functions</a> &#124;
<a href="#pub-methods">Member Functions</a> </div>
<div class="headertitle">
<div class="title">bad_allocation_size Class Reference<div class="ingroups"><a class="el" href="group__core.html">Core components</a></div></div> </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>The exception class thrown when an allocation size is bigger than the supported maximum. </p>
<p>This size is either the node, array or alignment parameter in a call to an allocation function. If those exceed the supported maximum returned by <code>max_node_size()</code>, <code>max_array_size()</code> or <code>max_alignment()</code>, one of its derived classes will be thrown or this class if in a situation where the type is unknown. It is derived from <code>std::bad_alloc</code>. Throwing can be prohibited by the handler function. </p><dl class="section note"><dt>Note</dt><dd>Even if all parameters are less than the maximum, <a class="el" href="classfoonathan_1_1memory_1_1out__of__memory.html">out_of_memory</a> or a similar exception can be thrown, because the maximum functions return an upper bound and not the actual supported maximum size, since it always depends on fence memory, alignment buffer and the like. </dd>
<dd>
A user should only <code>catch</code> for <code>bad_allocation_size</code>, not the derived classes. </dd>
<dd>
Most checks will only be done if <a class="el" href="group__core.html#gab9c74366ce94e4b30e7f8075fd46d3c9">FOONATHAN_MEMORY_CHECK_ALLOCATION_SIZE</a> is <code>true</code>. </dd></dl>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-types"></a>
Typedefs</h2></td></tr>
<tr class="memitem:a95368f33c6ef62ea6fbb432473a463fc"><td class="memItemLeft" align="right" valign="top">using&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfoonathan_1_1memory_1_1bad__allocation__size.html#a95368f33c6ef62ea6fbb432473a463fc">handler</a> = void(*)(const <a class="el" href="structfoonathan_1_1memory_1_1allocator__info.html">allocator_info</a> &amp;info, std::size_t passed, std::size_t supported)</td></tr>
<tr class="memdesc:a95368f33c6ef62ea6fbb432473a463fc"><td class="mdescLeft">&#160;</td><td class="mdescRight">The type of the handler called in the constructor of <a class="el" href="classfoonathan_1_1memory_1_1bad__allocation__size.html">bad_allocation_size</a>. <a href="classfoonathan_1_1memory_1_1bad__allocation__size.html#a95368f33c6ef62ea6fbb432473a463fc">More...</a><br /></td></tr>
<tr class="separator:a95368f33c6ef62ea6fbb432473a463fc"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-methods"></a>
Static Functions</h2></td></tr>
<tr class="memitem:aa7a04da7b79c7a572ee8a97fb18ffad2"><td class="memItemLeft" align="right" valign="top">static <a class="el" href="classfoonathan_1_1memory_1_1bad__allocation__size.html#a95368f33c6ef62ea6fbb432473a463fc">handler</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfoonathan_1_1memory_1_1bad__allocation__size.html#aa7a04da7b79c7a572ee8a97fb18ffad2">set_handler</a> (<a class="el" href="classfoonathan_1_1memory_1_1bad__allocation__size.html#a95368f33c6ef62ea6fbb432473a463fc">handler</a> h)</td></tr>
<tr class="separator:aa7a04da7b79c7a572ee8a97fb18ffad2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afa745d2aae73a3a9fa78400f9cfc22cf"><td class="memItemLeft" align="right" valign="top">static <a class="el" href="classfoonathan_1_1memory_1_1bad__allocation__size.html#a95368f33c6ef62ea6fbb432473a463fc">handler</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfoonathan_1_1memory_1_1bad__allocation__size.html#afa745d2aae73a3a9fa78400f9cfc22cf">get_handler</a> ()</td></tr>
<tr class="separator:afa745d2aae73a3a9fa78400f9cfc22cf"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Member Functions</h2></td></tr>
<tr class="memitem:adc63ca93b3e34f3c2ac908816a88ad68"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfoonathan_1_1memory_1_1bad__allocation__size.html#adc63ca93b3e34f3c2ac908816a88ad68">bad_allocation_size</a> (const <a class="el" href="structfoonathan_1_1memory_1_1allocator__info.html">allocator_info</a> &amp;info, std::size_t passed, std::size_t supported)</td></tr>
<tr class="separator:adc63ca93b3e34f3c2ac908816a88ad68"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aac1c33909e01e1dfc85617cf2477d3eb"><td class="memItemLeft" align="right" valign="top">const char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfoonathan_1_1memory_1_1bad__allocation__size.html#aac1c33909e01e1dfc85617cf2477d3eb">what</a> () const noexcept override</td></tr>
<tr class="separator:aac1c33909e01e1dfc85617cf2477d3eb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a18499b1d34f247dd7d2a1a436e5656cb"><td class="memItemLeft" align="right" valign="top">const <a class="el" href="structfoonathan_1_1memory_1_1allocator__info.html">allocator_info</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfoonathan_1_1memory_1_1bad__allocation__size.html#a18499b1d34f247dd7d2a1a436e5656cb">allocator</a> () const noexcept</td></tr>
<tr class="separator:a18499b1d34f247dd7d2a1a436e5656cb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2981505a16a405d7d5bf2fad95ef92be"><td class="memItemLeft" align="right" valign="top">std::size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfoonathan_1_1memory_1_1bad__allocation__size.html#a2981505a16a405d7d5bf2fad95ef92be">passed_value</a> () const noexcept</td></tr>
<tr class="separator:a2981505a16a405d7d5bf2fad95ef92be"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a57350e05e882556caa4449a39c040a5c"><td class="memItemLeft" align="right" valign="top">std::size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfoonathan_1_1memory_1_1bad__allocation__size.html#a57350e05e882556caa4449a39c040a5c">supported_value</a> () const noexcept</td></tr>
<tr class="separator:a57350e05e882556caa4449a39c040a5c"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Typedefs</h2>
<a id="a95368f33c6ef62ea6fbb432473a463fc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a95368f33c6ef62ea6fbb432473a463fc">&#9670;&nbsp;</a></span>handler</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">using <a class="el" href="classfoonathan_1_1memory_1_1bad__allocation__size.html#a95368f33c6ef62ea6fbb432473a463fc">handler</a> = void (*)(const <a class="el" href="structfoonathan_1_1memory_1_1allocator__info.html">allocator_info</a>&amp; info, std::size_t passed, std::size_t supported)</td>
</tr>
</table>
</div><div class="memdoc">
<p>The type of the handler called in the constructor of <a class="el" href="classfoonathan_1_1memory_1_1bad__allocation__size.html">bad_allocation_size</a>. </p>
<p>When a bad allocation size is detected and the exception object created, this handler gets called. It is especially useful if exception support is disabled. It gets the <a class="el" href="structfoonathan_1_1memory_1_1allocator__info.html">allocator_info</a>, the size passed to the function and the supported size (the latter is still an upper bound). </p><dl class="section user"><dt>Required Behavior:</dt><dd>It can log the error, throw a different exception derived from <code>std::bad_alloc</code> or abort the program. If it returns, this exception object will be created and thrown. </dd></dl>
<dl class="section user"><dt>Default Behavior:</dt><dd>On a hosted implementation it logs the error on <code>stderr</code> and continues execution, leading to this exception being thrown. On a freestanding implementation it does nothing. </dd></dl>
</div>
</div>
<h2 class="groupheader">Constructors</h2>
<a id="adc63ca93b3e34f3c2ac908816a88ad68"></a>
<h2 class="memtitle"><span class="permalink"><a href="#adc63ca93b3e34f3c2ac908816a88ad68">&#9670;&nbsp;</a></span>bad_allocation_size()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classfoonathan_1_1memory_1_1bad__allocation__size.html">bad_allocation_size</a> </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="structfoonathan_1_1memory_1_1allocator__info.html">allocator_info</a> &amp;&#160;</td>
<td class="paramname"><em>info</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">std::size_t&#160;</td>
<td class="paramname"><em>passed</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">std::size_t&#160;</td>
<td class="paramname"><em>supported</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section user"><dt>Effects:</dt><dd>Creates it by passing it the <a class="el" href="structfoonathan_1_1memory_1_1allocator__info.html">allocator_info</a>, the size passed to the allocation function and an upper bound on the supported size. It also calls the <a class="el" href="classfoonathan_1_1memory_1_1bad__allocation__size.html#a95368f33c6ef62ea6fbb432473a463fc">handler</a> to control whether or not it will be thrown. </dd></dl>
</div>
</div>
<h2 class="groupheader">Member Functions</h2>
<a id="aa7a04da7b79c7a572ee8a97fb18ffad2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa7a04da7b79c7a572ee8a97fb18ffad2">&#9670;&nbsp;</a></span>set_handler()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">static <a class="el" href="classfoonathan_1_1memory_1_1bad__allocation__size.html#a95368f33c6ef62ea6fbb432473a463fc">handler</a> set_handler </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classfoonathan_1_1memory_1_1bad__allocation__size.html#a95368f33c6ef62ea6fbb432473a463fc">handler</a>&#160;</td>
<td class="paramname"><em>h</em></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section user"><dt>Effects:</dt><dd>Sets <code>h</code> as the new <a class="el" href="classfoonathan_1_1memory_1_1bad__allocation__size.html#a95368f33c6ef62ea6fbb432473a463fc">handler</a> in an atomic operation. A <code>nullptr</code> sets the default <a class="el" href="classfoonathan_1_1memory_1_1bad__allocation__size.html#a95368f33c6ef62ea6fbb432473a463fc">handler</a>. </dd></dl>
<dl class="section user"><dt>Returns:</dt><dd>The previous <a class="el" href="classfoonathan_1_1memory_1_1bad__allocation__size.html#a95368f33c6ef62ea6fbb432473a463fc">handler</a>. This is never <code>nullptr</code>. </dd></dl>
</div>
</div>
<a id="afa745d2aae73a3a9fa78400f9cfc22cf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#afa745d2aae73a3a9fa78400f9cfc22cf">&#9670;&nbsp;</a></span>get_handler()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">static <a class="el" href="classfoonathan_1_1memory_1_1bad__allocation__size.html#a95368f33c6ef62ea6fbb432473a463fc">handler</a> get_handler </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section user"><dt>Returns:</dt><dd>The current <a class="el" href="classfoonathan_1_1memory_1_1bad__allocation__size.html#a95368f33c6ef62ea6fbb432473a463fc">handler</a>. This is never <code>nullptr</code>. </dd></dl>
</div>
</div>
<a id="aac1c33909e01e1dfc85617cf2477d3eb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aac1c33909e01e1dfc85617cf2477d3eb">&#9670;&nbsp;</a></span>what()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">const char* what </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">override</span><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section user"><dt>Returns:</dt><dd>A static NTBS that describes the error. It does not contain any specific information since there is no memory for formatting. </dd></dl>
</div>
</div>
<a id="a18499b1d34f247dd7d2a1a436e5656cb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a18499b1d34f247dd7d2a1a436e5656cb">&#9670;&nbsp;</a></span>allocator()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">const <a class="el" href="structfoonathan_1_1memory_1_1allocator__info.html">allocator_info</a>&amp; allocator </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section user"><dt>Returns:</dt><dd>The <a class="el" href="structfoonathan_1_1memory_1_1allocator__info.html">allocator_info</a> passed to it in the constructor. </dd></dl>
</div>
</div>
<a id="a2981505a16a405d7d5bf2fad95ef92be"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2981505a16a405d7d5bf2fad95ef92be">&#9670;&nbsp;</a></span>passed_value()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">std::size_t passed_value </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section user"><dt>Returns:</dt><dd>The size or alignment value that was passed to the allocation function which was too big. This is the same value passed to the constructor. </dd></dl>
</div>
</div>
<a id="a57350e05e882556caa4449a39c040a5c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a57350e05e882556caa4449a39c040a5c">&#9670;&nbsp;</a></span>supported_value()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">std::size_t supported_value </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section user"><dt>Returns:</dt><dd>An upper bound on the maximum supported size/alignment. It is only an upper bound, values below can fail, but values above will always fail. </dd></dl>
</div>
</div>
</div><!-- contents -->
<!-- HTML footer for doxygen 1.8.16-->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.18
</small></address>
</body>
</html>
1
https://gitee.com/mobangjack/memory.git
git@gitee.com:mobangjack/memory.git
mobangjack
memory
memory
gh-pages

搜索帮助