boost/python/long.hpp
はじめに
Python の long 整数型に対する TypeWrapper をエクスポートする。
クラス
long_
クラス
-
class long_ : public object
Python の組み込み
long
型の整数型プロトコルをエクスポートする。以下に定義するコンストラクタとメンバ関数のセマンティクスを完全に理解するには、TypeWrapper コンセプトの定義を読むことである。long_
はobject
から公開派生しているので、object
の公開インターフェイスはlong_
のインスタンスにも当てはまる。
long_
クラスの概要
namespace boost { namespace python
{
class long_ : public object
{
public:
long_(); // long_ を新規に作成する
template <class T>
explicit long_(T const& rhs);
template <class T, class U>
long_(T const& rhs, U const& base);
};
}}
例
namespace python = boost::python;
// オーバーフローすることなく階乗を計算する
python::long_ fact(long n)
{
if (n == 0)
return python::long_(1);
else
return n * fact(n - 1);
}