You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
190 lines
16 KiB
190 lines
16 KiB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
<title>LCOV - test.info - 9/bits/allocated_ptr.h</title>
|
|
<link rel="stylesheet" type="text/css" href="../../gcov.css">
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
|
|
<tr>
|
|
<td width="100%">
|
|
<table cellpadding=1 border=0 width="100%">
|
|
<tr>
|
|
<td width="10%" class="headerItem">Current view:</td>
|
|
<td width="35%" class="headerValue"><a href="../../index.html">top level</a> - <a href="index.html">9/bits</a> - allocated_ptr.h<span style="font-size: 80%;"> (source / <a href="allocated_ptr.h.func-sort-c.html">functions</a>)</span></td>
|
|
<td width="5%"></td>
|
|
<td width="15%"></td>
|
|
<td width="10%" class="headerCovTableHead">Hit</td>
|
|
<td width="10%" class="headerCovTableHead">Total</td>
|
|
<td width="15%" class="headerCovTableHead">Coverage</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="headerItem">Test:</td>
|
|
<td class="headerValue">test.info</td>
|
|
<td></td>
|
|
<td class="headerItem">Lines:</td>
|
|
<td class="headerCovTableEntry">9</td>
|
|
<td class="headerCovTableEntry">10</td>
|
|
<td class="headerCovTableEntryHi">90.0 %</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="headerItem">Date:</td>
|
|
<td class="headerValue">2022-06-07 00:30:42</td>
|
|
<td></td>
|
|
<td class="headerItem">Functions:</td>
|
|
<td class="headerCovTableEntry">3</td>
|
|
<td class="headerCovTableEntry">3</td>
|
|
<td class="headerCovTableEntryHi">100.0 %</td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td></td>
|
|
<td></td>
|
|
<td class="headerItem">Branches:</td>
|
|
<td class="headerCovTableEntry">1</td>
|
|
<td class="headerCovTableEntry">2</td>
|
|
<td class="headerCovTableEntryLo">50.0 %</td>
|
|
</tr>
|
|
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
</table>
|
|
|
|
<table cellpadding=0 cellspacing=0 border=0>
|
|
<tr>
|
|
<td><br></td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<pre class="sourceHeading"> Branch data Line data Source code</pre>
|
|
<pre class="source">
|
|
<a name="1"><span class="lineNum"> 1 </span> : : // Guarded Allocation -*- C++ -*-</a>
|
|
<a name="2"><span class="lineNum"> 2 </span> : : </a>
|
|
<a name="3"><span class="lineNum"> 3 </span> : : // Copyright (C) 2014-2019 Free Software Foundation, Inc.</a>
|
|
<a name="4"><span class="lineNum"> 4 </span> : : //</a>
|
|
<a name="5"><span class="lineNum"> 5 </span> : : // This file is part of the GNU ISO C++ Library. This library is free</a>
|
|
<a name="6"><span class="lineNum"> 6 </span> : : // software; you can redistribute it and/or modify it under the</a>
|
|
<a name="7"><span class="lineNum"> 7 </span> : : // terms of the GNU General Public License as published by the</a>
|
|
<a name="8"><span class="lineNum"> 8 </span> : : // Free Software Foundation; either version 3, or (at your option)</a>
|
|
<a name="9"><span class="lineNum"> 9 </span> : : // any later version.</a>
|
|
<a name="10"><span class="lineNum"> 10 </span> : : </a>
|
|
<a name="11"><span class="lineNum"> 11 </span> : : // This library is distributed in the hope that it will be useful,</a>
|
|
<a name="12"><span class="lineNum"> 12 </span> : : // but WITHOUT ANY WARRANTY; without even the implied warranty of</a>
|
|
<a name="13"><span class="lineNum"> 13 </span> : : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</a>
|
|
<a name="14"><span class="lineNum"> 14 </span> : : // GNU General Public License for more details.</a>
|
|
<a name="15"><span class="lineNum"> 15 </span> : : </a>
|
|
<a name="16"><span class="lineNum"> 16 </span> : : // Under Section 7 of GPL version 3, you are granted additional</a>
|
|
<a name="17"><span class="lineNum"> 17 </span> : : // permissions described in the GCC Runtime Library Exception, version</a>
|
|
<a name="18"><span class="lineNum"> 18 </span> : : // 3.1, as published by the Free Software Foundation.</a>
|
|
<a name="19"><span class="lineNum"> 19 </span> : : </a>
|
|
<a name="20"><span class="lineNum"> 20 </span> : : // You should have received a copy of the GNU General Public License and</a>
|
|
<a name="21"><span class="lineNum"> 21 </span> : : // a copy of the GCC Runtime Library Exception along with this program;</a>
|
|
<a name="22"><span class="lineNum"> 22 </span> : : // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see</a>
|
|
<a name="23"><span class="lineNum"> 23 </span> : : // <http://www.gnu.org/licenses/>.</a>
|
|
<a name="24"><span class="lineNum"> 24 </span> : : </a>
|
|
<a name="25"><span class="lineNum"> 25 </span> : : /** @file bits/allocated_ptr.h</a>
|
|
<a name="26"><span class="lineNum"> 26 </span> : : * This is an internal header file, included by other library headers.</a>
|
|
<a name="27"><span class="lineNum"> 27 </span> : : * Do not attempt to use it directly. @headername{memory}</a>
|
|
<a name="28"><span class="lineNum"> 28 </span> : : */</a>
|
|
<a name="29"><span class="lineNum"> 29 </span> : : </a>
|
|
<a name="30"><span class="lineNum"> 30 </span> : : #ifndef _ALLOCATED_PTR_H</a>
|
|
<a name="31"><span class="lineNum"> 31 </span> : : #define _ALLOCATED_PTR_H 1</a>
|
|
<a name="32"><span class="lineNum"> 32 </span> : : </a>
|
|
<a name="33"><span class="lineNum"> 33 </span> : : #if __cplusplus < 201103L</a>
|
|
<a name="34"><span class="lineNum"> 34 </span> : : # include <bits/c++0xwarning.h></a>
|
|
<a name="35"><span class="lineNum"> 35 </span> : : #else</a>
|
|
<a name="36"><span class="lineNum"> 36 </span> : : # include <type_traits></a>
|
|
<a name="37"><span class="lineNum"> 37 </span> : : # include <bits/ptr_traits.h></a>
|
|
<a name="38"><span class="lineNum"> 38 </span> : : # include <bits/alloc_traits.h></a>
|
|
<a name="39"><span class="lineNum"> 39 </span> : : </a>
|
|
<a name="40"><span class="lineNum"> 40 </span> : : namespace std _GLIBCXX_VISIBILITY(default)</a>
|
|
<a name="41"><span class="lineNum"> 41 </span> : : {</a>
|
|
<a name="42"><span class="lineNum"> 42 </span> : : _GLIBCXX_BEGIN_NAMESPACE_VERSION</a>
|
|
<a name="43"><span class="lineNum"> 43 </span> : : </a>
|
|
<a name="44"><span class="lineNum"> 44 </span> : : /// Non-standard RAII type for managing pointers obtained from allocators.</a>
|
|
<a name="45"><span class="lineNum"> 45 </span> : : template<typename _Alloc></a>
|
|
<a name="46"><span class="lineNum"> 46 </span> : : struct __allocated_ptr</a>
|
|
<a name="47"><span class="lineNum"> 47 </span> : : {</a>
|
|
<a name="48"><span class="lineNum"> 48 </span> : : using pointer = typename allocator_traits<_Alloc>::pointer;</a>
|
|
<a name="49"><span class="lineNum"> 49 </span> : : using value_type = typename allocator_traits<_Alloc>::value_type;</a>
|
|
<a name="50"><span class="lineNum"> 50 </span> : : </a>
|
|
<a name="51"><span class="lineNum"> 51 </span> : : /// Take ownership of __ptr</a>
|
|
<a name="52"><span class="lineNum"> 52 </span> :<span class="lineCov"> 18 : __allocated_ptr(_Alloc& __a, pointer __ptr) noexcept</span></a>
|
|
<a name="53"><span class="lineNum"> 53 </span> :<span class="lineCov"> 18 : : _M_alloc(std::__addressof(__a)), _M_ptr(__ptr)</span></a>
|
|
<a name="54"><span class="lineNum"> 54 </span> :<span class="lineCov"> 18 : { }</span></a>
|
|
<a name="55"><span class="lineNum"> 55 </span> : : </a>
|
|
<a name="56"><span class="lineNum"> 56 </span> : : /// Convert __ptr to allocator's pointer type and take ownership of it</a>
|
|
<a name="57"><span class="lineNum"> 57 </span> : : template<typename _Ptr,</a>
|
|
<a name="58"><span class="lineNum"> 58 </span> : : typename _Req = _Require<is_same<_Ptr, value_type*>>></a>
|
|
<a name="59"><span class="lineNum"> 59 </span> : : __allocated_ptr(_Alloc& __a, _Ptr __ptr)</a>
|
|
<a name="60"><span class="lineNum"> 60 </span> : : : _M_alloc(std::__addressof(__a)),</a>
|
|
<a name="61"><span class="lineNum"> 61 </span> : : _M_ptr(pointer_traits<pointer>::pointer_to(*__ptr))</a>
|
|
<a name="62"><span class="lineNum"> 62 </span> : : { }</a>
|
|
<a name="63"><span class="lineNum"> 63 </span> : : </a>
|
|
<a name="64"><span class="lineNum"> 64 </span> : : /// Transfer ownership of the owned pointer</a>
|
|
<a name="65"><span class="lineNum"> 65 </span> : : __allocated_ptr(__allocated_ptr&& __gd) noexcept</a>
|
|
<a name="66"><span class="lineNum"> 66 </span> : : : _M_alloc(__gd._M_alloc), _M_ptr(__gd._M_ptr)</a>
|
|
<a name="67"><span class="lineNum"> 67 </span> : : { __gd._M_ptr = nullptr; }</a>
|
|
<a name="68"><span class="lineNum"> 68 </span> : : </a>
|
|
<a name="69"><span class="lineNum"> 69 </span> : : /// Deallocate the owned pointer</a>
|
|
<a name="70"><span class="lineNum"> 70 </span> :<span class="lineCov"> 18 : ~__allocated_ptr()</span></a>
|
|
<a name="71"><span class="lineNum"> 71 </span> : : {</a>
|
|
<a name="72"><span class="lineNum"> 72 </span> [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 18 times"> + </span>]:<span class="lineCov"> 18 : if (_M_ptr != nullptr)</span></a>
|
|
<a name="73"><span class="lineNum"> 73 </span> :<span class="lineNoCov"> 0 : std::allocator_traits<_Alloc>::deallocate(*_M_alloc, _M_ptr, 1);</span></a>
|
|
<a name="74"><span class="lineNum"> 74 </span> :<span class="lineCov"> 18 : }</span></a>
|
|
<a name="75"><span class="lineNum"> 75 </span> : : </a>
|
|
<a name="76"><span class="lineNum"> 76 </span> : : /// Release ownership of the owned pointer</a>
|
|
<a name="77"><span class="lineNum"> 77 </span> : : __allocated_ptr&</a>
|
|
<a name="78"><span class="lineNum"> 78 </span> :<span class="lineCov"> 18 : operator=(std::nullptr_t) noexcept</span></a>
|
|
<a name="79"><span class="lineNum"> 79 </span> : : {</a>
|
|
<a name="80"><span class="lineNum"> 80 </span> :<span class="lineCov"> 18 : _M_ptr = nullptr;</span></a>
|
|
<a name="81"><span class="lineNum"> 81 </span> :<span class="lineCov"> 18 : return *this;</span></a>
|
|
<a name="82"><span class="lineNum"> 82 </span> : : }</a>
|
|
<a name="83"><span class="lineNum"> 83 </span> : : </a>
|
|
<a name="84"><span class="lineNum"> 84 </span> : : /// Get the address that the owned pointer refers to.</a>
|
|
<a name="85"><span class="lineNum"> 85 </span> : : value_type* get() { return std::__to_address(_M_ptr); }</a>
|
|
<a name="86"><span class="lineNum"> 86 </span> : : </a>
|
|
<a name="87"><span class="lineNum"> 87 </span> : : private:</a>
|
|
<a name="88"><span class="lineNum"> 88 </span> : : _Alloc* _M_alloc;</a>
|
|
<a name="89"><span class="lineNum"> 89 </span> : : pointer _M_ptr;</a>
|
|
<a name="90"><span class="lineNum"> 90 </span> : : };</a>
|
|
<a name="91"><span class="lineNum"> 91 </span> : : </a>
|
|
<a name="92"><span class="lineNum"> 92 </span> : : /// Allocate space for a single object using __a</a>
|
|
<a name="93"><span class="lineNum"> 93 </span> : : template<typename _Alloc></a>
|
|
<a name="94"><span class="lineNum"> 94 </span> : : __allocated_ptr<_Alloc></a>
|
|
<a name="95"><span class="lineNum"> 95 </span> : : __allocate_guarded(_Alloc& __a)</a>
|
|
<a name="96"><span class="lineNum"> 96 </span> : : {</a>
|
|
<a name="97"><span class="lineNum"> 97 </span> : : return { __a, std::allocator_traits<_Alloc>::allocate(__a, 1) };</a>
|
|
<a name="98"><span class="lineNum"> 98 </span> : : }</a>
|
|
<a name="99"><span class="lineNum"> 99 </span> : : </a>
|
|
<a name="100"><span class="lineNum"> 100 </span> : : _GLIBCXX_END_NAMESPACE_VERSION</a>
|
|
<a name="101"><span class="lineNum"> 101 </span> : : } // namespace std</a>
|
|
<a name="102"><span class="lineNum"> 102 </span> : : </a>
|
|
<a name="103"><span class="lineNum"> 103 </span> : : #endif</a>
|
|
<a name="104"><span class="lineNum"> 104 </span> : : #endif</a>
|
|
</pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<br>
|
|
|
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
<tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.14</a></td></tr>
|
|
</table>
|
|
<br>
|
|
|
|
</body>
|
|
</html>
|