PageRenderTime 72ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 1ms

/src/Thirdparty/boost.xint/libs/xint/doc/integer_8hpp_source.html

https://github.com/vividos/MultiplayerOnlineGame
HTML | 1971 lines | 1970 code | 0 blank | 1 comment | 0 complexity | 6b8aa29e3c5a588bd16b8126dc006a39 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <title>The Extended Integer (XInt) Library: integer.hpp Source File</title>
  6. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  7. <link href="doxygen.css" rel="stylesheet" type="text/css"/>
  8. </head>
  9. <body>
  10. <!-- Generated by Doxygen 1.7.1 -->
  11. <div class="navigation" id="top">
  12. <div class="tabs">
  13. <ul class="tablist">
  14. <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
  15. <li><a href="namespaces.html"><span>Namespaces</span></a></li>
  16. <li><a href="annotated.html"><span>Classes</span></a></li>
  17. <li class="current"><a href="files.html"><span>Files</span></a></li>
  18. </ul>
  19. </div>
  20. <div class="tabs2">
  21. <ul class="tablist">
  22. <li><a href="files.html"><span>File&nbsp;List</span></a></li>
  23. <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
  24. </ul>
  25. </div>
  26. <div class="header">
  27. <div class="headertitle">
  28. <h1>integer.hpp</h1> </div>
  29. </div>
  30. <div class="contents">
  31. <a href="integer_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
  32. <a name="l00002"></a>00002 <span class="comment">/*</span>
  33. <a name="l00003"></a>00003 <span class="comment"> The Extended Integer (XInt) Library</span>
  34. <a name="l00004"></a>00004 <span class="comment"> A fast, portable C++ library for multi-precision integer math</span>
  35. <a name="l00005"></a>00005 <span class="comment"> Copyright 2010 by Chad Nelson</span>
  36. <a name="l00006"></a>00006 <span class="comment"></span>
  37. <a name="l00007"></a>00007 <span class="comment"> Distributed under the Boost Software License, Version 1.0.</span>
  38. <a name="l00008"></a>00008 <span class="comment"> See accompanying file LICENSE_1_0.txt or copy at</span>
  39. <a name="l00009"></a>00009 <span class="comment"> http://www.boost.org/LICENSE_1_0.txt</span>
  40. <a name="l00010"></a>00010 <span class="comment"></span>
  41. <a name="l00011"></a>00011 <span class="comment"> See http://www.boost.org/libs/xint for library home page.</span>
  42. <a name="l00012"></a>00012 <span class="comment">*/</span>
  43. <a name="l00013"></a>00013
  44. <a name="l00018"></a>00018 <span class="preprocessor">#ifndef BOOST_INCLUDED_XINT_INTEGER_HPP</span>
  45. <a name="l00019"></a>00019 <span class="preprocessor"></span><span class="preprocessor">#define BOOST_INCLUDED_XINT_INTEGER_HPP</span>
  46. <a name="l00020"></a>00020 <span class="preprocessor"></span>
  47. <a name="l00021"></a>00021 <span class="preprocessor">#ifdef _MSC_VER</span>
  48. <a name="l00022"></a>00022 <span class="preprocessor"></span> <span class="comment">// C4127, &quot;conditional expression is constant&quot;. Unfortunately the policy-</span>
  49. <a name="l00023"></a>00023 <span class="comment">// based design of this library triggers a lot of these, even though the</span>
  50. <a name="l00024"></a>00024 <span class="comment">// code is correct as written.</span>
  51. <a name="l00025"></a>00025 <span class="preprocessor"> #pragma warning(push)</span>
  52. <a name="l00026"></a>00026 <span class="preprocessor"></span><span class="preprocessor"> #pragma warning(disable: 4127)</span>
  53. <a name="l00027"></a>00027 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
  54. <a name="l00028"></a>00028 <span class="preprocessor"></span>
  55. <a name="l00029"></a>00029 <span class="preprocessor">#include &quot;<a class="code" href="internals_8hpp.html" title="Contains the internal definitions required for all XInt types.">detail/internals.hpp</a>&quot;</span>
  56. <a name="l00030"></a>00030 <span class="preprocessor">#include &quot;<a class="code" href="random_8hpp.html" title="Declares items relating to random numbers.">random.hpp</a>&quot;</span>
  57. <a name="l00031"></a>00031
  58. <a name="l00032"></a>00032 <span class="keyword">namespace </span>boost {
  59. <a name="l00033"></a>00033 <span class="keyword">namespace </span>xint {
  60. <a name="l00034"></a>00034
  61. <a name="l00079"></a>00079 <span class="keyword">template</span>&lt;BOOST_XINT_INITIAL_APARAMS&gt;
  62. <a name="l00080"></a>00080 <span class="keyword">class </span>integer_t: <span class="keyword">virtual</span> <span class="keyword">public</span> detail::integer_t_data&lt;BOOST_XINT_APARAMS&gt;,
  63. <a name="l00081"></a>00081 <span class="keyword">public</span> detail::nan_functions&lt;detail::integer_t_data&lt;BOOST_XINT_APARAMS&gt;::
  64. <a name="l00082"></a>00082 NothrowType::value, integer_t&lt;BOOST_XINT_APARAMS&gt;, BOOST_XINT_APARAMS&gt;,
  65. <a name="l00083"></a>00083 <span class="keyword">public</span> detail::fixed_functions&lt;detail::integer_t_data&lt;BOOST_XINT_APARAMS&gt;::
  66. <a name="l00084"></a>00084 BitsType::value, integer_t&lt;BOOST_XINT_APARAMS&gt;, BOOST_XINT_APARAMS&gt;, <span class="keyword">public</span>
  67. <a name="l00085"></a>00085 detail::unsigned_negative_functions&lt;detail::integer_t_data&lt;
  68. <a name="l00086"></a>00086 BOOST_XINT_APARAMS&gt;::SignType::value, BOOST_XINT_APARAMS&gt;
  69. <a name="l00087"></a>00087 {
  70. <a name="l00088"></a>00088 <span class="keyword">typedef</span> <span class="keyword">typename</span> detail::integer_t_data&lt;BOOST_XINT_APARAMS&gt;::BitsType
  71. <a name="l00089"></a>00089 BitsType;
  72. <a name="l00090"></a>00090 <span class="keyword">typedef</span> <span class="keyword">typename</span> detail::integer_t_data&lt;BOOST_XINT_APARAMS&gt;::SecureType
  73. <a name="l00091"></a>00091 SecureType;
  74. <a name="l00092"></a>00092 <span class="keyword">typedef</span> <span class="keyword">typename</span> detail::integer_t_data&lt;BOOST_XINT_APARAMS&gt;::SignType
  75. <a name="l00093"></a>00093 SignType;
  76. <a name="l00094"></a>00094 <span class="keyword">typedef</span> <span class="keyword">typename</span> detail::integer_t_data&lt;BOOST_XINT_APARAMS&gt;::Alloc Alloc;
  77. <a name="l00095"></a>00095
  78. <a name="l00096"></a>00096 <span class="keyword">public</span>:
  79. <a name="l00097"></a>00097 <span class="preprocessor"> #ifndef BOOST_XINT_DOXYGEN_IGNORE</span>
  80. <a name="l00098"></a>00098 <span class="preprocessor"></span> <span class="keyword">typedef</span> integer_t&lt;BOOST_XINT_APARAMS&gt; type;
  81. <a name="l00099"></a>00099 <span class="keyword">typedef</span> void (integer_t&lt;BOOST_XINT_APARAMS&gt;::*safe_bool_type)() <span class="keyword">const</span>;
  82. <a name="l00100"></a><a class="code" href="classboost_1_1xint_1_1integer__t.html#aa596f21475c016ead49722d887a97ab4">00100</a> <span class="keywordtype">void</span> this_is_a_safe_bool_type()<span class="keyword"> const </span>{ }
  83. <a name="l00101"></a>00101
  84. <a name="l00102"></a><a class="code" href="classboost_1_1xint_1_1integer__t.html#a130f5eeae0a95847b7bb5cb56e443480">00102</a> <span class="keyword">typedef</span> <span class="keyword">typename</span> detail::integer_t_data&lt;BOOST_XINT_APARAMS&gt;::datatype
  85. <a name="l00103"></a>00103 datatype;
  86. <a name="l00104"></a>00104
  87. <a name="l00105"></a><a class="code" href="classboost_1_1xint_1_1integer__t.html#abe691a26ef01695197d98d01822ea764">00105</a> <span class="keyword">using</span> detail::integer_t_data&lt;BOOST_XINT_APARAMS&gt;::Threadsafe;
  88. <a name="l00106"></a>00106 <span class="keyword">using</span> detail::integer_t_data&lt;BOOST_XINT_APARAMS&gt;::Nothrow;
  89. <a name="l00107"></a><a class="code" href="classboost_1_1xint_1_1integer__t.html#ac15850352ec856e1a380209214cf8563">00107</a> <span class="keyword">using</span> detail::integer_t_data&lt;BOOST_XINT_APARAMS&gt;::Signed;
  90. <a name="l00108"></a>00108
  91. <a name="l00109"></a><a class="code" href="classboost_1_1xint_1_1integer__t.html#aa7bc0f108496999a375d55ad26e40dcf">00109</a> <span class="keyword">using</span> detail::integer_t_data&lt;BOOST_XINT_APARAMS&gt;::data;
  92. <a name="l00110"></a><a class="code" href="classboost_1_1xint_1_1integer__t.html#a9754bfd54c9e30e071b0e5bc1b099f8b">00110</a> <span class="keyword">using</span> detail::integer_t_data&lt;BOOST_XINT_APARAMS&gt;::_data;
  93. <a name="l00111"></a>00111
  94. <a name="l00112"></a>00112 <span class="keyword">using</span> detail::nan_functions&lt;detail::integer_t_data&lt;
  95. <a name="l00113"></a>00113 <a class="code" href="options_8hpp.html#aa350afa46bc87068c0cefb1925130b6c">BOOST_XINT_APARAMS</a>&gt;::NothrowType::value, <a class="code" href="classboost_1_1xint_1_1integer__t.html" title="The integer_t class template.">integer_t</a>&lt;
  96. <a name="l00114"></a>00114 <a class="code" href="options_8hpp.html#aa350afa46bc87068c0cefb1925130b6c">BOOST_XINT_APARAMS</a>&gt;, <a class="code" href="options_8hpp.html#aa350afa46bc87068c0cefb1925130b6c">BOOST_XINT_APARAMS</a>&gt;::is_nan;
  97. <a name="l00115"></a>00115
  98. <a name="l00116"></a>00116 <span class="keyword">using</span> detail::unsigned_negative_functions&lt;detail::integer_t_data&lt;
  99. <a name="l00117"></a>00117 <a class="code" href="options_8hpp.html#aa350afa46bc87068c0cefb1925130b6c">BOOST_XINT_APARAMS</a>&gt;::SignType::value, <a class="code" href="options_8hpp.html#aa350afa46bc87068c0cefb1925130b6c">BOOST_XINT_APARAMS</a>&gt;::
  100. <a name="l00118"></a>00118 _fix_negative_unsigned;
  101. <a name="l00119"></a>00119 <span class="preprocessor"> #endif // BOOST_XINT_DOXYGEN_IGNORE</span>
  102. <a name="l00120"></a>00120 <span class="preprocessor"></span>
  103. <a name="l00123"></a>00123 <a class="code" href="classboost_1_1xint_1_1integer__t.html#adc039392b5197a0ebd69b5744ee420eb" title="Creates a new integer with an initial value of zero.">integer_t</a>();
  104. <a name="l00124"></a>00124 <a class="code" href="classboost_1_1xint_1_1integer__t.html#adc039392b5197a0ebd69b5744ee420eb" title="Creates a new integer with an initial value of zero.">integer_t</a>(<span class="keyword">const</span> <a class="code" href="classboost_1_1xint_1_1integer__t.html" title="The integer_t class template.">integer_t&lt;BOOST_XINT_APARAMS&gt;</a> &amp;b, <span class="keywordtype">bool</span> force_thread_safety =
  105. <a name="l00125"></a>00125 <span class="keyword">false</span>);
  106. <a name="l00127"></a>00127 <a class="code" href="classboost_1_1xint_1_1integer__t.html#adc039392b5197a0ebd69b5744ee420eb" title="Creates a new integer with an initial value of zero.">integer_t</a>(<a class="code" href="basic__types__and__includes_8hpp.html#a0533c283bce9e4d9468ea9b3a5ab509b">BOOST_XINT_RV_REF</a>(type) i) { _swap(i); }
  107. <a name="l00128"></a>00128 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> <span class="keywordtype">char</span>T&gt;
  108. <a name="l00129"></a>00129 <span class="keyword">explicit</span> <a class="code" href="classboost_1_1xint_1_1integer__t.html#adc039392b5197a0ebd69b5744ee420eb" title="Creates a new integer with an initial value of zero.">integer_t</a>(<span class="keyword">const</span> charT *str, std::size_t base = 10);
  109. <a name="l00130"></a>00130 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> <span class="keywordtype">char</span>T&gt;
  110. <a name="l00131"></a>00131 <a class="code" href="classboost_1_1xint_1_1integer__t.html#adc039392b5197a0ebd69b5744ee420eb" title="Creates a new integer with an initial value of zero.">integer_t</a>(<span class="keyword">const</span> charT *str, <span class="keyword">const</span> charT *&amp;endptr, std::size_t base = 10);
  111. <a name="l00132"></a>00132 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> <span class="keywordtype">char</span>T, <span class="keyword">typename</span> traitsT, <span class="keyword">typename</span> allocT&gt;
  112. <a name="l00133"></a>00133 <span class="keyword">explicit</span> <a class="code" href="classboost_1_1xint_1_1integer__t.html#adc039392b5197a0ebd69b5744ee420eb" title="Creates a new integer with an initial value of zero.">integer_t</a>(<span class="keyword">const</span> std::basic_string&lt;charT, traitsT, allocT&gt; &amp;str,
  113. <a name="l00134"></a>00134 std::size_t base = 10);
  114. <a name="l00135"></a>00135 <a class="code" href="classboost_1_1xint_1_1integer__t.html#adc039392b5197a0ebd69b5744ee420eb" title="Creates a new integer with an initial value of zero.">integer_t</a>(<span class="keyword">const</span> <a class="code" href="namespaceboost_1_1xint.html#aae3128529370506165793f2771834e58" title="The format for the binary representations of integers.">xint::binary_t</a> &amp;b, <a class="code" href="namespaceboost_1_1xint.html#ae9f6d103df04ad19a841ed3f8b94a764" title="This makes it easier to tell when an item is measured in bits.">bitsize_t</a> bits = 0);
  115. <a name="l00136"></a>00136 <span class="keyword">template</span> &lt;BOOST_XINT_CLASS_BPARAMS&gt; <span class="keyword">explicit</span> <a class="code" href="classboost_1_1xint_1_1integer__t.html#adc039392b5197a0ebd69b5744ee420eb" title="Creates a new integer with an initial value of zero.">integer_t</a>(<span class="keyword">const</span>
  116. <a name="l00137"></a>00137 <a class="code" href="classboost_1_1xint_1_1integer__t.html" title="The integer_t class template.">integer_t&lt;BOOST_XINT_BPARAMS&gt;</a> &amp;other, <span class="keywordtype">bool</span> force_thread_safety = <span class="keyword">false</span>);
  117. <a name="l00138"></a>00138 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Type&gt; <a class="code" href="classboost_1_1xint_1_1integer__t.html#adc039392b5197a0ebd69b5744ee420eb" title="Creates a new integer with an initial value of zero.">integer_t</a>(<span class="keyword">const</span> Type n, <span class="keyword">typename</span>
  118. <a name="l00139"></a>00139 boost::enable_if&lt;boost::is_integral&lt;Type&gt; &gt;::type* = 0);
  119. <a name="l00140"></a>00140
  120. <a name="l00141"></a>00141 <span class="preprocessor"> #ifndef BOOST_XINT_DOXYGEN_IGNORE</span>
  121. <a name="l00142"></a>00142 <span class="preprocessor"></span>
  122. <a name="l00143"></a>00143 <span class="keyword">explicit</span> <a class="code" href="classboost_1_1xint_1_1integer__t.html#adc039392b5197a0ebd69b5744ee420eb" title="Creates a new integer with an initial value of zero.">integer_t</a>(<span class="keyword">const</span> detail::raw_integer_t&lt;BitsType::value,
  123. <a name="l00144"></a>00144 SecureType::value, Alloc&gt; &amp;c):
  124. <a name="l00145"></a>00145 detail::integer_t_data&lt;<a class="code" href="options_8hpp.html#aa350afa46bc87068c0cefb1925130b6c">BOOST_XINT_APARAMS</a>&gt;(c) { <span class="keywordflow">if</span> (Threadsafe == <span class="keyword">true</span>)
  125. <a name="l00146"></a>00146 _data().make_unique(); }
  126. <a name="l00147"></a>00147 <span class="preprocessor"> #endif // BOOST_XINT_DOXYGEN_IGNORE</span>
  127. <a name="l00148"></a>00148 <span class="preprocessor"></span>
  128. <a name="l00149"></a>00149
  129. <a name="l00155"></a>00155 integer_t&lt;BOOST_XINT_APARAMS&gt;&amp; <a class="code" href="classboost_1_1xint_1_1integer__t.html#a7388d85a6b1509c214b981bc730f7c7f">operator=</a>(<a class="code" href="basic__types__and__includes_8hpp.html#a8177a6a6c68ea042f7e644d8ef7128f9">BOOST_XINT_COPY_ASSIGN_REF</a>(type)
  130. <a name="l00156"></a><a class="code" href="classboost_1_1xint_1_1integer__t.html#ab7a2481c7347c73bd927286879404bba">00156</a> c);
  131. <a name="l00157"></a>00157 <a class="code" href="classboost_1_1xint_1_1integer__t.html" title="The integer_t class template.">integer_t&lt;BOOST_XINT_APARAMS&gt;</a>&amp; <a class="code" href="classboost_1_1xint_1_1integer__t.html#a7388d85a6b1509c214b981bc730f7c7f">operator=</a>(<a class="code" href="basic__types__and__includes_8hpp.html#a0533c283bce9e4d9468ea9b3a5ab509b">BOOST_XINT_RV_REF</a>(type) c) {
  132. <a name="l00158"></a>00158 _swap(c); <span class="keywordflow">return</span> *<span class="keyword">this</span>; }
  133. <a name="l00159"></a>00159 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Type&gt; <a class="code" href="classboost_1_1xint_1_1integer__t.html" title="The integer_t class template.">integer_t&lt;BOOST_XINT_APARAMS&gt;</a>&amp; <a class="code" href="classboost_1_1xint_1_1integer__t.html#a7388d85a6b1509c214b981bc730f7c7f">operator=</a>(<span class="keyword">const</span> Type
  134. <a name="l00160"></a>00160 n) { <a class="code" href="classboost_1_1xint_1_1integer__t.html" title="The integer_t class template.">integer_t&lt;BOOST_XINT_APARAMS&gt;</a> nn(n); _swap(nn); <span class="keywordflow">return</span> *<span class="keyword">this</span>; }
  135. <a name="l00161"></a>00161
  136. <a name="l00162"></a>00162 <a class="code" href="classboost_1_1xint_1_1integer__t.html#abe691a26ef01695197d98d01822ea764">operator safe_bool_type</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> (data.is_zero() ? 0 :
  137. <a name="l00163"></a>00163 &amp;integer_t&lt;BOOST_XINT_APARAMS&gt;::this_is_a_safe_bool_type); }
  138. <a name="l00164"></a>00164 <span class="keywordtype">bool</span> <a class="code" href="classboost_1_1xint_1_1integer__t.html#ac15850352ec856e1a380209214cf8563">operator!</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> data.is_zero(); }
  139. <a name="l00165"></a>00165 integer_t&lt;BOOST_XINT_APARAMS&gt; <a class="code" href="classboost_1_1xint_1_1integer__t.html#a31ef623fef7944861c458bcd2c9b0001" title="Return the additive inverse of an integer.">operator-</a>() <span class="keyword">const</span>;
  140. <a name="l00166"></a>00166 integer_t&lt;BOOST_XINT_APARAMS&gt;&amp; <a class="code" href="classboost_1_1xint_1_1integer__t.html#aa7bc0f108496999a375d55ad26e40dcf">operator+</a>() { <span class="keywordflow">return</span> *<span class="keyword">this</span>; }
  141. <a name="l00167"></a>00167 <span class="keyword">const</span> integer_t&lt;BOOST_XINT_APARAMS&gt;&amp; <a class="code" href="classboost_1_1xint_1_1integer__t.html#aa7bc0f108496999a375d55ad26e40dcf">operator+</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> *<span class="keyword">this</span>; }
  142. <a name="l00168"></a>00168
  143. <a name="l00169"></a>00169 <span class="preprocessor"> #ifdef BOOST_XINT_DOXYGEN_IGNORE // inherited, only here for doxygen</span>
  144. <a name="l00170"></a>00170 <span class="preprocessor"></span> integer_t&lt;BOOST_XINT_APARAMS&gt; <a class="code" href="classboost_1_1xint_1_1integer__t.html#ad200ae35a1bb12061b9a230f9e42550d" title="The Bitwise Ones Complement (i.e. bitwise NOT) operator.">operator~</a>() <span class="keyword">const</span>;
  145. <a name="l00171"></a>00171 <span class="preprocessor"> #endif</span>
  146. <a name="l00172"></a>00172 <span class="preprocessor"></span>
  147. <a name="l00173"></a>00173 integer_t&lt;BOOST_XINT_APARAMS&gt;&amp; <a class="code" href="classboost_1_1xint_1_1integer__t.html#a117a5f7325a2f1a77b0d5dd31fd920c6">operator+=</a>(<span class="keyword">const</span>
  148. <a name="l00174"></a>00174 integer_t&lt;BOOST_XINT_APARAMS&gt; &amp;b);
  149. <a name="l00175"></a>00175 integer_t&lt;BOOST_XINT_APARAMS&gt;&amp; <a class="code" href="classboost_1_1xint_1_1integer__t.html#a67009eed89894e082b609b0890e371cd">operator-=</a>(<span class="keyword">const</span>
  150. <a name="l00176"></a>00176 integer_t&lt;BOOST_XINT_APARAMS&gt; &amp;b);
  151. <a name="l00177"></a>00177 integer_t&lt;BOOST_XINT_APARAMS&gt;&amp; <a class="code" href="classboost_1_1xint_1_1integer__t.html#a1932ceee3f8344c15059732250bac0df">operator*=</a>(<span class="keyword">const</span>
  152. <a name="l00178"></a>00178 integer_t&lt;BOOST_XINT_APARAMS&gt; &amp;b);
  153. <a name="l00179"></a>00179 integer_t&lt;BOOST_XINT_APARAMS&gt;&amp; <a class="code" href="classboost_1_1xint_1_1integer__t.html#a582f45204112c860bd4884fa51c25aad">operator/=</a>(<span class="keyword">const</span>
  154. <a name="l00180"></a>00180 integer_t&lt;BOOST_XINT_APARAMS&gt; &amp;b);
  155. <a name="l00181"></a>00181 integer_t&lt;BOOST_XINT_APARAMS&gt;&amp; <a class="code" href="classboost_1_1xint_1_1integer__t.html#ac05bea273dfad811ba2addd164d1042b">operator%=</a>(<span class="keyword">const</span>
  156. <a name="l00182"></a>00182 integer_t&lt;BOOST_XINT_APARAMS&gt; &amp;b);
  157. <a name="l00183"></a>00183
  158. <a name="l00184"></a>00184 integer_t&lt;BOOST_XINT_APARAMS&gt;&amp; <a class="code" href="classboost_1_1xint_1_1integer__t.html#a719c2966d9e29521eb95863eaa2ec570">operator++</a>();
  159. <a name="l00185"></a>00185 integer_t&lt;BOOST_XINT_APARAMS&gt;&amp; <a class="code" href="classboost_1_1xint_1_1integer__t.html#abdbcf3ae2ff508e5fc9467b85f9e917c">operator--</a>();
  160. <a name="l00186"></a>00186 integer_t&lt;BOOST_XINT_APARAMS&gt; <a class="code" href="classboost_1_1xint_1_1integer__t.html#a719c2966d9e29521eb95863eaa2ec570">operator++</a>(<span class="keywordtype">int</span>);
  161. <a name="l00187"></a>00187 integer_t&lt;BOOST_XINT_APARAMS&gt; <a class="code" href="classboost_1_1xint_1_1integer__t.html#abdbcf3ae2ff508e5fc9467b85f9e917c">operator--</a>(<span class="keywordtype">int</span>);
  162. <a name="l00188"></a>00188
  163. <a name="l00189"></a>00189 integer_t&lt;BOOST_XINT_APARAMS&gt;&amp; <a class="code" href="classboost_1_1xint_1_1integer__t.html#a395d69ce8b4a4fa5e8967f3b658de8ea">operator&amp;=</a>(<span class="keyword">const</span>
  164. <a name="l00190"></a>00190 integer_t&lt;BOOST_XINT_APARAMS&gt; &amp;n);
  165. <a name="l00191"></a>00191 integer_t&lt;BOOST_XINT_APARAMS&gt;&amp; <a class="code" href="classboost_1_1xint_1_1integer__t.html#a7a92ce81071327d56d0c21a6b37f62d9">operator|=</a>(<span class="keyword">const</span>
  166. <a name="l00192"></a>00192 integer_t&lt;BOOST_XINT_APARAMS&gt; &amp;n);
  167. <a name="l00193"></a>00193 integer_t&lt;BOOST_XINT_APARAMS&gt;&amp; <a class="code" href="classboost_1_1xint_1_1integer__t.html#a194e4dbdffddde2704de6267f271f53a">operator^=</a>(<span class="keyword">const</span>
  168. <a name="l00194"></a>00194 integer_t&lt;BOOST_XINT_APARAMS&gt; &amp;n);
  169. <a name="l00195"></a>00195 integer_t&lt;BOOST_XINT_APARAMS&gt; <a class="code" href="classboost_1_1xint_1_1integer__t.html#aee68d28e7f5803902ad153dbfab2e8ad" title="Left-shift an integer by a specified number of bits.">operator&lt;&lt;</a>(<a class="code" href="namespaceboost_1_1xint.html#ae9f6d103df04ad19a841ed3f8b94a764" title="This makes it easier to tell when an item is measured in bits.">bitsize_t</a> shift) <span class="keyword">const</span>;
  170. <a name="l00196"></a>00196 integer_t&lt;BOOST_XINT_APARAMS&gt; <a class="code" href="classboost_1_1xint_1_1integer__t.html#afe9a935bb9de506b29f043b439a196ae" title="Right-shift an integer by a specified number of bits.">operator&gt;&gt;</a>(<a class="code" href="namespaceboost_1_1xint.html#ae9f6d103df04ad19a841ed3f8b94a764" title="This makes it easier to tell when an item is measured in bits.">bitsize_t</a> shift) <span class="keyword">const</span>;
  171. <a name="l00197"></a>00197 integer_t&lt;BOOST_XINT_APARAMS&gt;&amp; <a class="code" href="classboost_1_1xint_1_1integer__t.html#a516ce52ae1a8332a1de8711baaea0943">operator&lt;&lt;=</a>(<a class="code" href="namespaceboost_1_1xint.html#ae9f6d103df04ad19a841ed3f8b94a764" title="This makes it easier to tell when an item is measured in bits.">bitsize_t</a> shift);
  172. <a name="l00198"></a>00198 integer_t&lt;BOOST_XINT_APARAMS&gt;&amp; <a class="code" href="classboost_1_1xint_1_1integer__t.html#aa67123e331f61cd7c54e6fb84e09609f">operator&gt;&gt;=</a>(<a class="code" href="namespaceboost_1_1xint.html#ae9f6d103df04ad19a841ed3f8b94a764" title="This makes it easier to tell when an item is measured in bits.">bitsize_t</a> shift);
  173. <a name="l00200"></a>00200
  174. <a name="l00203"></a>00203 <span class="keywordtype">bool</span> <a class="code" href="classboost_1_1xint_1_1integer__t.html#a28c1cf2549da47e36ada1e3a2a020654" title="Tests the lowest bit of *this to determine oddness.">is_odd</a>() <span class="keyword">const</span>;
  175. <a name="l00204"></a>00204 <span class="keywordtype">bool</span> <a class="code" href="classboost_1_1xint_1_1integer__t.html#af7d57cc73521c4d72bc853435127b790" title="Tests the lowest bit of *this to determine evenness.">is_even</a>() <span class="keyword">const</span>;
  176. <a name="l00205"></a>00205 <span class="keywordtype">int</span> <a class="code" href="classboost_1_1xint_1_1integer__t.html#aa278c48753019fe3deaa623eecdb16b3" title="Tests the sign of *this.">sign</a>(<span class="keywordtype">bool</span> signed_zero = <span class="keyword">false</span>) <span class="keyword">const</span>;
  177. <a name="l00206"></a>00206 std::size_t <a class="code" href="classboost_1_1xint_1_1integer__t.html#a6575f1fd58be6bf73145459b4b46afbb" title="Tells you roughly how large *this is.">hex_digits</a>() <span class="keyword">const</span>;
  178. <a name="l00207"></a>00207
  179. <a name="l00208"></a>00208 <span class="preprocessor"> #ifdef BOOST_XINT_DOXYGEN_IGNORE // inherited, only here for doxygen</span>
  180. <a name="l00209"></a>00209 <span class="preprocessor"></span> <span class="keywordtype">bool</span> <a class="code" href="classboost_1_1xint_1_1integer__t.html#a9afdf728b490f4fea0f6bd4805e96bd5" title="Tests whether the object is a Not-a-Number.">is_nan</a>() <span class="keyword">const</span>;
  181. <a name="l00210"></a>00210 <span class="preprocessor"> #endif</span>
  182. <a name="l00211"></a>00211 <span class="preprocessor"></span>
  183. <a name="l00212"></a>00212
  184. <a name="l00213"></a>00213 <span class="keyword">typedef</span> base_divide_t&lt;integer_t&lt;BOOST_XINT_APARAMS&gt; &gt; divide_t;
  185. <a name="l00214"></a>00214
  186. <a name="l00222"></a>00222
  187. <a name="l00223"></a>00223 <span class="keyword">static</span> integer_t&lt;BOOST_XINT_APARAMS&gt; <a class="code" href="classboost_1_1xint_1_1integer__t.html#a22a32f5e1926ced95b9400e87dfe9349" title="Calculate the value of 2e">pow2</a>(std::size_t exponent);
  188. <a name="l00224"></a>00224 <span class="keyword">static</span> integer_t&lt;BOOST_XINT_APARAMS&gt; <a class="code" href="classboost_1_1xint_1_1integer__t.html#a16b836e12f76f2560ee697fb399dbc2e" title="Calculate the value of n! ">factorial</a>(std::size_t n);
  189. <a name="l00225"></a>00225
  190. <a name="l00226"></a>00226 <span class="preprocessor"> #ifdef BOOST_XINT_DOXYGEN_IGNORE // inherited, only here for doxygen</span>
  191. <a name="l00227"></a>00227 <span class="preprocessor"></span> <span class="keyword">static</span> integer_t&lt;BOOST_XINT_APARAMS&gt; <a class="code" href="classboost_1_1xint_1_1integer__t.html#a26cf36c3ec3664dc91b8aaa86748247d" title="Returns a Not-a-Number value, for types that support it.">nan</a>();
  192. <a name="l00228"></a>00228 <span class="preprocessor"> #endif</span>
  193. <a name="l00229"></a>00229 <span class="preprocessor"></span>
  194. <a name="l00230"></a>00230 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Type&gt; <span class="keyword">static</span> integer_t&lt;BOOST_XINT_APARAMS&gt;
  195. <a name="l00231"></a>00231 <a class="code" href="classboost_1_1xint_1_1integer__t.html#a1d7c4d0ae13e84bbac07e6c6eb01334e" title="Generates a random integer with specific attributes.">random_by_size</a>(Type &amp;gen, <a class="code" href="namespaceboost_1_1xint.html#ae9f6d103df04ad19a841ed3f8b94a764" title="This makes it easier to tell when an item is measured in bits.">bitsize_t</a> size_in_bits, <span class="keywordtype">bool</span> high_bit_on =
  196. <a name="l00232"></a>00232 <span class="keyword">false</span>, <span class="keywordtype">bool</span> low_bit_on = <span class="keyword">false</span>, <span class="keywordtype">bool</span> can_be_negative = <span class="keyword">false</span>);
  197. <a name="l00233"></a>00233 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Type&gt; <span class="keyword">static</span> integer_t&lt;BOOST_XINT_APARAMS&gt;
  198. <a name="l00234"></a>00234 <a class="code" href="classboost_1_1xint_1_1integer__t.html#afbbf1fba0d65e5348b1771003ba40ae1" title="Generate a randomly-generated prime number of a particular bit-size.">random_prime</a>(Type &amp;gen, <a class="code" href="namespaceboost_1_1xint.html#ae9f6d103df04ad19a841ed3f8b94a764" title="This makes it easier to tell when an item is measured in bits.">bitsize_t</a> size_in_bits, <a class="code" href="namespaceboost_1_1xint.html#a48deb76c9c428a4b3a50177b1b0cb547" title="A callback function takes no parameters and returns a bool.">callback_t</a> callback =
  199. <a name="l00235"></a>00235 <a class="code" href="namespaceboost_1_1xint.html#a758d415a476a5eeed28dc6b5869b1696" title="An empty callback_t, used as a default parameter for some functions.">no_callback</a>);
  200. <a name="l00237"></a>00237
  201. <a name="l00238"></a>00238 <span class="preprocessor"> #ifndef BOOST_XINT_DOXYGEN_IGNORE</span>
  202. <a name="l00239"></a>00239 <span class="preprocessor"></span>
  203. <a name="l00240"></a>00240
  204. <a name="l00241"></a>00241 <span class="keywordtype">void</span> _swap(integer_t&lt;BOOST_XINT_APARAMS&gt; &amp;s) { <span class="keyword">using</span> std::swap;
  205. <a name="l00242"></a>00242 <a class="code" href="namespaceboost_1_1xint.html#aecbaaf9b2c679d8b6f220224a6bab8dc">swap</a>(data, s.data); }
  206. <a name="l00244"></a>00244 <span class="preprocessor"> #endif</span>
  207. <a name="l00245"></a>00245 <span class="preprocessor"></span>
  208. <a name="l00246"></a>00246 <span class="keyword">private</span>:
  209. <a name="l00247"></a>00247 <a class="code" href="basic__types__and__includes_8hpp.html#a5f5634ec80010f0f87b93320fa3419f9">BOOST_XINT_COPYABLE_AND_MOVABLE</a>(type)
  210. <a name="l00248"></a>00248 };
  211. <a name="l00249"></a>00249
  212. <a name="l00251"></a>00251 <span class="comment">// Member function template definitions</span>
  213. <a name="l00252"></a><a class="code" href="classboost_1_1xint_1_1integer__t.html#adc039392b5197a0ebd69b5744ee420eb">00252</a>
  214. <a name="l00254"></a>00254 <span class="keyword">template</span>&lt;BOOST_XINT_CLASS_APARAMS&gt;
  215. <a name="l00255"></a>00255 <a class="code" href="classboost_1_1xint_1_1integer__t.html#adc039392b5197a0ebd69b5744ee420eb" title="Creates a new integer with an initial value of zero.">integer_t&lt;BOOST_XINT_APARAMS&gt;::integer_t</a>() {
  216. <a name="l00256"></a>00256 <span class="comment">// Don&#39;t need to do anything, already preinitialized to zero.</span>
  217. <a name="l00257"></a>00257 }
  218. <a name="l00258"></a>00258
  219. <a name="l00269"></a>00269 <span class="keyword">template</span>&lt;BOOST_XINT_CLASS_APARAMS&gt;
  220. <a name="l00270"></a>00270 <a class="code" href="classboost_1_1xint_1_1integer__t.html#adc039392b5197a0ebd69b5744ee420eb" title="Creates a new integer with an initial value of zero.">integer_t&lt;BOOST_XINT_APARAMS&gt;::integer_t</a>(<span class="keyword">const</span> <a class="code" href="classboost_1_1xint_1_1integer__t.html" title="The integer_t class template.">integer_t&lt;BOOST_XINT_APARAMS&gt;</a> &amp;i,
  221. <a name="l00271"></a>00271 <span class="keywordtype">bool</span> force_thread_safety)
  222. <a name="l00272"></a>00272 {
  223. <a name="l00273"></a>00273 <span class="keywordflow">if</span> (Nothrow) {
  224. <a name="l00274"></a>00274 <a class="code" href="internals_8hpp.html#a693c4f473d303c632864f6084c394f03">BOOST_XINT_TRY</a> {
  225. <a name="l00275"></a>00275 data = i.data;
  226. <a name="l00276"></a>00276 <span class="keywordflow">if</span> (!data.is_nan()) {
  227. <a name="l00277"></a>00277 <span class="keywordflow">if</span> (force_thread_safety || Threadsafe == <span class="keyword">true</span>)
  228. <a name="l00278"></a>00278 data.make_unique();
  229. <a name="l00279"></a>00279 }
  230. <a name="l00280"></a>00280 } <a class="code" href="internals_8hpp.html#a5117d87820df153f9c26dd5ff8ac318a">BOOST_XINT_CATCH</a> {
  231. <a name="l00281"></a>00281 data.make_nan();
  232. <a name="l00282"></a>00282 }
  233. <a name="l00283"></a>00283 } <span class="keywordflow">else</span> {
  234. <a name="l00284"></a>00284 data = i.data;
  235. <a name="l00285"></a>00285 <span class="keywordflow">if</span> (force_thread_safety || Threadsafe == <span class="keyword">true</span>) data.make_unique();
  236. <a name="l00286"></a>00286 }
  237. <a name="l00287"></a>00287 }
  238. <a name="l00288"></a>00288
  239. <a name="l00290"></a>00290 <span class="keyword">template</span>&lt;BOOST_XINT_CLASS_APARAMS&gt;
  240. <a name="l00291"></a>00291 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> <span class="keywordtype">char</span>T&gt;
  241. <a name="l00292"></a>00292 <a class="code" href="classboost_1_1xint_1_1integer__t.html#adc039392b5197a0ebd69b5744ee420eb" title="Creates a new integer with an initial value of zero.">integer_t&lt;BOOST_XINT_APARAMS&gt;::integer_t</a>(<span class="keyword">const</span> charT *str, std::size_t base) {
  242. <a name="l00293"></a>00293 <span class="keywordflow">if</span> (Nothrow) {
  243. <a name="l00294"></a>00294 <a class="code" href="internals_8hpp.html#a693c4f473d303c632864f6084c394f03">BOOST_XINT_TRY</a> {
  244. <a name="l00295"></a>00295 <span class="keyword">const</span> std::basic_string&lt;charT&gt; &amp;tnan = detail::nan_text&lt;charT&gt;();
  245. <a name="l00296"></a>00296 <span class="keywordflow">if</span> (str[0] == tnan[0] &amp;&amp; std::basic_string&lt;charT&gt;(str) == tnan) {
  246. <a name="l00297"></a>00297 data.make_nan();
  247. <a name="l00298"></a>00298 } <span class="keywordflow">else</span> {
  248. <a name="l00299"></a>00299 data.from_string(str, base);
  249. <a name="l00300"></a>00300 <span class="keywordflow">if</span> (!Signed &amp;&amp; data.negative) _fix_negative_unsigned();
  250. <a name="l00301"></a>00301 }
  251. <a name="l00302"></a>00302 } <a class="code" href="internals_8hpp.html#a5117d87820df153f9c26dd5ff8ac318a">BOOST_XINT_CATCH</a> {
  252. <a name="l00303"></a>00303 data.make_nan();
  253. <a name="l00304"></a>00304 }
  254. <a name="l00305"></a>00305 } <span class="keywordflow">else</span> {
  255. <a name="l00306"></a>00306 data.from_string(str, base);
  256. <a name="l00307"></a>00307 <span class="keywordflow">if</span> (!Signed &amp;&amp; data.negative) _fix_negative_unsigned();
  257. <a name="l00308"></a>00308 }
  258. <a name="l00309"></a>00309 }
  259. <a name="l00310"></a>00310
  260. <a name="l00339"></a>00339 <span class="keyword">template</span>&lt;BOOST_XINT_CLASS_APARAMS&gt;
  261. <a name="l00340"></a>00340 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> <span class="keywordtype">char</span>T&gt;
  262. <a name="l00341"></a>00341 <a class="code" href="classboost_1_1xint_1_1integer__t.html#adc039392b5197a0ebd69b5744ee420eb" title="Creates a new integer with an initial value of zero.">integer_t&lt;BOOST_XINT_APARAMS&gt;::integer_t</a>(<span class="keyword">const</span> charT *str, <span class="keyword">const</span> charT *&amp;endptr,
  263. <a name="l00342"></a>00342 std::size_t base)
  264. <a name="l00343"></a>00343 {
  265. <a name="l00344"></a>00344 <span class="keywordflow">if</span> (Nothrow) {
  266. <a name="l00345"></a>00345 <a class="code" href="internals_8hpp.html#a693c4f473d303c632864f6084c394f03">BOOST_XINT_TRY</a> {
  267. <a name="l00346"></a>00346 <span class="keyword">const</span> std::basic_string&lt;charT&gt; &amp;tnan = detail::nan_text&lt;charT&gt;();
  268. <a name="l00347"></a>00347 <span class="keywordflow">if</span> (str[0] == tnan[0]) {
  269. <a name="l00348"></a>00348 std::basic_string&lt;charT&gt; s(str);
  270. <a name="l00349"></a>00349 <span class="keywordflow">if</span> (s.substr(0, tnan.length()) == tnan) {
  271. <a name="l00350"></a>00350 data.make_nan();
  272. <a name="l00351"></a>00351 endptr = str + tnan.length();
  273. <a name="l00352"></a>00352 <span class="keywordflow">return</span>;
  274. <a name="l00353"></a>00353 }
  275. <a name="l00354"></a>00354 }
  276. <a name="l00355"></a>00355 data.from_string(str, endptr, base);
  277. <a name="l00356"></a>00356 <span class="keywordflow">if</span> (!Signed &amp;&amp; data.negative) _fix_negative_unsigned();
  278. <a name="l00357"></a>00357 } <a class="code" href="internals_8hpp.html#a5117d87820df153f9c26dd5ff8ac318a">BOOST_XINT_CATCH</a> {
  279. <a name="l00358"></a>00358 data.make_nan();
  280. <a name="l00359"></a>00359 }
  281. <a name="l00360"></a>00360 } <span class="keywordflow">else</span> {
  282. <a name="l00361"></a>00361 data.from_string(str, endptr, base);
  283. <a name="l00362"></a>00362 <span class="keywordflow">if</span> (!Signed &amp;&amp; data.negative) _fix_negative_unsigned();
  284. <a name="l00363"></a>00363 }
  285. <a name="l00364"></a>00364 }
  286. <a name="l00365"></a>00365
  287. <a name="l00390"></a>00390 <span class="keyword">template</span>&lt;BOOST_XINT_CLASS_APARAMS&gt;
  288. <a name="l00391"></a>00391 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> <span class="keywordtype">char</span>T, <span class="keyword">typename</span> traitsT, <span class="keyword">typename</span> allocT&gt;
  289. <a name="l00392"></a>00392 <a class="code" href="classboost_1_1xint_1_1integer__t.html#adc039392b5197a0ebd69b5744ee420eb" title="Creates a new integer with an initial value of zero.">integer_t&lt;BOOST_XINT_APARAMS&gt;::integer_t</a>(<span class="keyword">const</span> std::basic_string&lt;charT, traitsT,
  290. <a name="l00393"></a>00393 allocT&gt; &amp;str, std::size_t base)
  291. <a name="l00394"></a>00394 {
  292. <a name="l00395"></a>00395 <span class="keywordflow">if</span> (Nothrow) {
  293. <a name="l00396"></a>00396 <a class="code" href="internals_8hpp.html#a693c4f473d303c632864f6084c394f03">BOOST_XINT_TRY</a> {
  294. <a name="l00397"></a>00397 <span class="keywordflow">if</span> (str == detail::nan_text&lt;charT&gt;()) data.make_nan();
  295. <a name="l00398"></a>00398 <span class="keywordflow">else</span> {
  296. <a name="l00399"></a>00399 data.from_string(str, base);
  297. <a name="l00400"></a>00400 <span class="keywordflow">if</span> (!Signed &amp;&amp; data.negative) _fix_negative_unsigned();
  298. <a name="l00401"></a>00401 }
  299. <a name="l00402"></a>00402 } <a class="code" href="internals_8hpp.html#a5117d87820df153f9c26dd5ff8ac318a">BOOST_XINT_CATCH</a> {
  300. <a name="l00403"></a>00403 data.make_nan();
  301. <a name="l00404"></a>00404 }
  302. <a name="l00405"></a>00405 } <span class="keywordflow">else</span> {
  303. <a name="l00406"></a>00406 data.from_string(str, base);
  304. <a name="l00407"></a>00407 <span class="keywordflow">if</span> (!Signed &amp;&amp; data.negative) _fix_negative_unsigned();
  305. <a name="l00408"></a>00408 }
  306. <a name="l00409"></a>00409 }
  307. <a name="l00410"></a>00410
  308. <a name="l00432"></a>00432 <span class="keyword">template</span>&lt;BOOST_XINT_CLASS_APARAMS&gt;
  309. <a name="l00433"></a>00433 <a class="code" href="classboost_1_1xint_1_1integer__t.html#adc039392b5197a0ebd69b5744ee420eb" title="Creates a new integer with an initial value of zero.">integer_t&lt;BOOST_XINT_APARAMS&gt;::integer_t</a>(<span class="keyword">const</span> <a class="code" href="namespaceboost_1_1xint.html#aae3128529370506165793f2771834e58" title="The format for the binary representations of integers.">xint::binary_t</a> &amp;i, <a class="code" href="namespaceboost_1_1xint.html#ae9f6d103df04ad19a841ed3f8b94a764" title="This makes it easier to tell when an item is measured in bits.">bitsize_t</a>
  310. <a name="l00434"></a>00434 bits)
  311. <a name="l00435"></a>00435 {
  312. <a name="l00436"></a>00436 <span class="keywordflow">if</span> (Nothrow) {
  313. <a name="l00437"></a>00437 <a class="code" href="internals_8hpp.html#a693c4f473d303c632864f6084c394f03">BOOST_XINT_TRY</a> {
  314. <a name="l00438"></a>00438 data.from_binary(i, bits);
  315. <a name="l00439"></a>00439 } <a class="code" href="internals_8hpp.html#a5117d87820df153f9c26dd5ff8ac318a">BOOST_XINT_CATCH</a> {
  316. <a name="l00440"></a>00440 data.make_nan();
  317. <a name="l00441"></a>00441 }
  318. <a name="l00442"></a>00442 } <span class="keywordflow">else</span> {
  319. <a name="l00443"></a>00443 data.from_binary(i, bits);
  320. <a name="l00444"></a>00444 }
  321. <a name="l00445"></a>00445 }
  322. <a name="l00446"></a>00446
  323. <a name="l00459"></a>00459 <span class="keyword">template</span>&lt;BOOST_XINT_CLASS_APARAMS&gt;
  324. <a name="l00460"></a>00460 <span class="keyword">template</span> &lt;BOOST_XINT_CLASS_BPARAMS&gt;
  325. <a name="l00461"></a>00461 <a class="code" href="classboost_1_1xint_1_1integer__t.html#adc039392b5197a0ebd69b5744ee420eb" title="Creates a new integer with an initial value of zero.">integer_t&lt;BOOST_XINT_APARAMS&gt;::integer_t</a>(<span class="keyword">const</span> integer_t&lt;BOOST_XINT_BPARAMS&gt; &amp;i,
  326. <a name="l00462"></a>00462 <span class="keywordtype">bool</span> force_thread_safety)
  327. <a name="l00463"></a>00463 {
  328. <a name="l00464"></a>00464 <span class="keywordflow">if</span> (Nothrow) {
  329. <a name="l00465"></a>00465 <a class="code" href="internals_8hpp.html#a693c4f473d303c632864f6084c394f03">BOOST_XINT_TRY</a> {
  330. <a name="l00466"></a>00466 <span class="keywordflow">if</span> (i.is_nan()) {
  331. <a name="l00467"></a>00467 data.make_nan();
  332. <a name="l00468"></a>00468 } <span class="keywordflow">else</span> {
  333. <a name="l00469"></a>00469 data = i._data();
  334. <a name="l00470"></a>00470 <span class="keywordflow">if</span> (!data.is_nan()) {
  335. <a name="l00471"></a>00471 <span class="keywordflow">if</span> (force_thread_safety || Threadsafe == <span class="keyword">true</span>)
  336. <a name="l00472"></a>00472 data.make_unique();
  337. <a name="l00473"></a>00473 <span class="keywordflow">if</span> (!Signed &amp;&amp; data.negative) _fix_negative_unsigned();
  338. <a name="l00474"></a>00474 }
  339. <a name="l00475"></a>00475 }
  340. <a name="l00476"></a>00476 } <a class="code" href="internals_8hpp.html#a5117d87820df153f9c26dd5ff8ac318a">BOOST_XINT_CATCH</a> {
  341. <a name="l00477"></a>00477 data.make_nan();
  342. <a name="l00478"></a>00478 }
  343. <a name="l00479"></a>00479 } <span class="keywordflow">else</span> {
  344. <a name="l00480"></a>00480 <span class="keywordflow">if</span> (i._data().is_nan()) detail::exception_handler&lt;&gt;::call(__FILE__,
  345. <a name="l00481"></a>00481 __LINE__, exceptions::not_a_number());
  346. <a name="l00482"></a>00482 data = i._data();
  347. <a name="l00483"></a>00483 <span class="keywordflow">if</span> (force_thread_safety || Threadsafe == <span class="keyword">true</span>) data.make_unique();
  348. <a name="l00484"></a>00484 <span class="keywordflow">if</span> (!Signed &amp;&amp; data.negative) _fix_negative_unsigned();
  349. <a name="l00485"></a>00485 }
  350. <a name="l00486"></a>00486 }
  351. <a name="l00487"></a>00487
  352. <a name="l00500"></a>00500 <span class="keyword">template</span>&lt;BOOST_XINT_CLASS_APARAMS&gt;
  353. <a name="l00501"></a>00501 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Type&gt; <a class="code" href="classboost_1_1xint_1_1integer__t.html#adc039392b5197a0ebd69b5744ee420eb" title="Creates a new integer with an initial value of zero.">integer_t&lt;BOOST_XINT_APARAMS&gt;::integer_t</a>(<span class="keyword">const</span> Type n,
  354. <a name="l00502"></a>00502 <span class="keyword">typename</span> boost::enable_if&lt;boost::is_integral&lt;Type&gt; &gt;::type*)
  355. <a name="l00503"></a>00503 {
  356. <a name="l00504"></a>00504 <span class="keywordflow">if</span> (Nothrow) {
  357. <a name="l00505"></a>00505 <a class="code" href="internals_8hpp.html#a693c4f473d303c632864f6084c394f03">BOOST_XINT_TRY</a> {
  358. <a name="l00506"></a>00506 <span class="keywordflow">if</span> (std::numeric_limits&lt;Type&gt;::is_signed) {
  359. <a name="l00507"></a>00507 data.set_signed(n);
  360. <a name="l00508"></a>00508 <span class="keywordflow">if</span> (!Signed &amp;&amp; data.negative) _fix_negative_unsigned();
  361. <a name="l00509"></a>00509 } <span class="keywordflow">else</span> data.set_unsigned(n);
  362. <a name="l00510"></a>00510 } <a class="code" href="internals_8hpp.html#a5117d87820df153f9c26dd5ff8ac318a">BOOST_XINT_CATCH</a> {
  363. <a name="l00511"></a>00511 data.make_nan();
  364. <a name="l00512"></a>00512 }
  365. <a name="l00513"></a>00513 } <span class="keywordflow">else</span> {
  366. <a name="l00514"></a>00514 <span class="keywordflow">if</span> (std::numeric_limits&lt;Type&gt;::is_signed) {
  367. <a name="l00515"></a>00515 data.set_signed(n);
  368. <a name="l00516"></a>00516 <span class="keywordflow">if</span> (!Signed &amp;&amp; data.negative) _fix_negative_unsigned();
  369. <a name="l00517"></a>00517 } <span class="keywordflow">else</span> data.set_unsigned(n);
  370. <a name="l00518"></a>00518 }
  371. <a name="l00519"></a>00519 }
  372. <a name="l00520"></a><a class="code" href="classboost_1_1xint_1_1integer__t.html#a7388d85a6b1509c214b981bc730f7c7f">00520</a>
  373. <a name="l00521"></a>00521 <span class="keyword">template</span>&lt;BOOST_XINT_CLASS_APARAMS&gt;
  374. <a name="l00522"></a>00522 <a class="code" href="classboost_1_1xint_1_1integer__t.html" title="The integer_t class template.">integer_t&lt;BOOST_XINT_APARAMS&gt;</a>&amp; <a class="code" href="classboost_1_1xint_1_1integer__t.html#a7388d85a6b1509c214b981bc730f7c7f">integer_t&lt;BOOST_XINT_APARAMS&gt;::</a>
  375. <a name="l00523"></a>00523 <a class="code" href="classboost_1_1xint_1_1integer__t.html#a7388d85a6b1509c214b981bc730f7c7f"> operator=</a>(<a class="code" href="basic__types__and__includes_8hpp.html#a8177a6a6c68ea042f7e644d8ef7128f9">BOOST_XINT_COPY_ASSIGN_REF</a>(type) c)
  376. <a name="l00524"></a>00524 {
  377. <a name="l00525"></a>00525 <span class="keywordflow">if</span> (Nothrow) {
  378. <a name="l00526"></a>00526 <span class="keywordflow">if</span> (c._data().is_nan()) data.make_nan();
  379. <a name="l00527"></a>00527 <span class="keywordflow">else</span> {
  380. <a name="l00528"></a>00528 <a class="code" href="internals_8hpp.html#a693c4f473d303c632864f6084c394f03">BOOST_XINT_TRY</a> {
  381. <a name="l00529"></a>00529 data = c.data;
  382. <a name="l00530"></a>00530 <span class="keywordflow">if</span> (Threadsafe == <span class="keyword">true</span>) data.make_unique();
  383. <a name="l00531"></a>00531 } <a class="code" href="internals_8hpp.html#a5117d87820df153f9c26dd5ff8ac318a">BOOST_XINT_CATCH</a> {
  384. <a name="l00532"></a>00532 data.make_nan();
  385. <a name="l00533"></a>00533 }
  386. <a name="l00534"></a>00534 }
  387. <a name="l00535"></a>00535 } <span class="keywordflow">else</span> {
  388. <a name="l00536"></a>00536 data = c.data;
  389. <a name="l00537"></a>00537 <span class="keywordflow">if</span> (Threadsafe == <span class="keyword">true</span>) data.make_unique();
  390. <a name="l00538"></a>00538 }
  391. <a name="l00539"></a>00539 <span class="keywordflow">return</span> *<span class="keyword">this</span>;
  392. <a name="l00540"></a>00540 }
  393. <a name="l00541"></a>00541
  394. <a name="l00542"></a>00542 <span class="preprocessor">#ifdef BOOST_XINT_DOXYGEN_IGNORE // Doesn&#39;t really exist, this is here for docs</span>
  395. <a name="l00543"></a>00543 <span class="preprocessor"></span>
  396. <a name="l00559"></a>00559 <span class="keyword">template</span>&lt;BOOST_XINT_CLASS_APARAMS&gt;
  397. <a name="l00560"></a>00560 <a class="code" href="classboost_1_1xint_1_1integer__t.html" title="The integer_t class template.">integer_t&lt;BOOST_XINT_APARAMS&gt;</a> <a class="code" href="classboost_1_1xint_1_1integer__t.html#ad200ae35a1bb12061b9a230f9e42550d" title="The Bitwise Ones Complement (i.e. bitwise NOT) operator.">integer_t&lt;BOOST_XINT_APARAMS&gt;::operator~</a>() <span class="keyword">const</span>;
  398. <a name="l00561"></a>00561 <span class="preprocessor">#endif // BOOST_XINT_DOXYGEN_IGNORE</span>
  399. <a name="l00562"></a>00562 <span class="preprocessor"></span>
  400. <a name="l00569"></a>00569 <span class="keyword">template</span>&lt;BOOST_XINT_CLASS_APARAMS&gt;
  401. <a name="l00570"></a>00570 <a class="code" href="classboost_1_1xint_1_1integer__t.html" title="The integer_t class template.">integer_t&lt;BOOST_XINT_APARAMS&gt;</a> <a class="code" href="classboost_1_1xint_1_1integer__t.html#a31ef623fef7944861c458bcd2c9b0001" title="Return the additive inverse of an integer.">integer_t&lt;BOOST_XINT_APARAMS&gt;::operator-</a>()<span class="keyword"> const </span>{
  402. <a name="l00571"></a>00571 <span class="keywordflow">if</span> (Nothrow) {
  403. <a name="l00572"></a>00572 <span class="keywordflow">if</span> (<a class="code" href="classboost_1_1xint_1_1integer__t.html#a9afdf728b490f4fea0f6bd4805e96bd5" title="Tests whether the object is a Not-a-Number.">is_nan</a>()) <span class="keywordflow">return</span> *<span class="keyword">this</span>;
  404. <a name="l00573"></a>00573 <a class="code" href="internals_8hpp.html#a693c4f473d303c632864f6084c394f03">BOOST_XINT_TRY</a> {
  405. <a name="l00574"></a>00574 <a class="code" href="classboost_1_1xint_1_1integer__t.html" title="The integer_t class template.">integer_t&lt;BOOST_XINT_APARAMS&gt;</a> r(*<span class="keyword">this</span>);
  406. <a name="l00575"></a>00575 <span class="keywordflow">if</span> (Threadsafe == <span class="keyword">true</span>) r._make_unique();
  407. <a name="l00576"></a>00576 r.data = -r.data;
  408. <a name="l00577"></a>00577 <span class="keywordflow">if</span> (!Signed &amp;&amp; r.data.negative) r._fix_negative_unsigned();
  409. <a name="l00578"></a>00578 <span class="keywordflow">return</span> <a class="code" href="basic__types__and__includes_8hpp.html#a73c3b02410381da656b7cb59c7ba9314">BOOST_XINT_MOVE</a>(r);
  410. <a name="l00579"></a>00579 } <a class="code" href="internals_8hpp.html#a5117d87820df153f9c26dd5ff8ac318a">BOOST_XINT_CATCH</a> {
  411. <a name="l00580"></a>00580 <span class="keywordflow">return</span> detail::get_nan&lt;integer_t&lt;BOOST_XINT_APARAMS&gt; &gt;();
  412. <a name="l00581"></a>00581 }
  413. <a name="l00582"></a>00582 } <span class=

Large files files are truncated, but you can click here to view the full file