summaryrefslogtreecommitdiff
path: root/libs/python/doc/v2/long.html
blob: 08ceb3bd5c6bc071251fa3280879f616230d7f1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<!-- Copyright David Abrahams 2006. Distributed under the Boost -->
<!-- Software License, Version 1.0. (See accompanying -->
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
<html>
  <head>
    <meta name="generator" content=
    "HTML Tidy for Windows (vers 1st August 2002), see www.w3.org">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link rel="stylesheet" type="text/css" href="../boost.css">

    <title>Boost.Python - &lt;boost/python/long.hpp&gt;</title>
  </head>

  <body>
    <table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
    "header">
      <tr>
        <td valign="top" width="300">
          <h3><a href="../../../../index.htm"><img height="86" width="277"
          alt="C++ Boost" src="../../../../boost.png" border="0"></a></h3>
        </td>

        <td valign="top">
          <h1 align="center"><a href="../index.html">Boost.Python</a></h1>

          <h2 align="center">Header &lt;boost/python/long.hpp&gt;</h2>
        </td>
      </tr>
    </table>
    <hr>

    <h2>Contents</h2>

    <dl class="page-index">
      <dt><a href="#introduction">Introduction</a></dt>

      <dt><a href="#classes">Classes</a></dt>

      <dd>
        <dl class="page-index">
          <dt><a href="#long_-spec">Class <code>long_</code></a></dt>

          <dd>
            <dl class="page-index">
              <dt><a href="#long_-spec-synopsis">Class <code>long_</code>
              synopsis</a></dt>
            </dl>
          </dd>
        </dl>
      </dd>

      <dt><a href="#examples">Example(s)</a></dt>
    </dl>
    <hr>

    <h2><a name="introduction"></a>Introduction</h2>

    <p>Exposes a <a href=
    "ObjectWrapper.html#TypeWrapper-concept">TypeWrapper</a> for the Python
    <a href=
    "http://www.python.org/doc/current/lib/typesnumeric.html">long</a>
    integer type.</p>

    <h2><a name="classes"></a>Classes</h2>

    <h3><a name="long_-spec"></a>Class <code>long_</code></h3>

    <p>Exposes the <a href=
    "http://www.python.org/doc/current/lib/typesnumeric.html">numeric type
    protocol</a> of Python's built-in <code>long</code> type. The semantics
    of the constructors and member functions defined below can be fully
    understood by reading the <a href=
    "ObjectWrapper.html#TypeWrapper-concept">TypeWrapper</a> concept
    definition. Since <code>long_</code> is publicly derived from <code><a
    href="object.html#object-spec">object</a></code>, the public object
    interface applies to <code>long_</code> instances as well.</p>

    <h4><a name="long_-spec-synopsis"></a>Class <code>long_</code>
    synopsis</h4>
<pre>
namespace boost { namespace python
{
  class long_ : public object
  {
   public:
      long_(); // new long_

      template &lt;class T&gt;
      explicit long_(T const&amp; rhs);

      template &lt;class T, class U&gt;
      long_(T const&amp; rhs, U const&amp; base);
  };
}}
</pre>

    <h2><a name="examples"></a>Example</h2>
<pre>
namespace python = boost::python;

// compute a factorial without overflowing
python::long_ fact(long n)
{
   if (n == 0)
      return python::long_(1);
   else
      return n * fact(n - 1);
}
</pre>

    <p>Revised 1 October, 2002</p>

    <p><i>&copy; Copyright <a href=
    "http://www.boost.org/people/dave_abrahams.htm">Dave Abrahams</a> 2002.</i></p>
  </body>
</html>