boost/python/tuple.hpp

はじめに

Python の tuple 型に対する TypeWrapper をエクスポートする。

クラス

tuple クラス

class tuple : public object

Python の組み込み tuple インターフェイスをエクスポートする。以下に定義するコンストラクタとメンバ関数のセマンティクスを完全に理解するには、TypeWrapper コンセプトの定義を読むことである。tupleobject から公開派生しているので、object の公開インターフェイスは tuple のインスタンスにも当てはまる。

tuple クラスの概要

namespace boost { namespace python
{
   class tuple : public object
   {
      // tuple() は空の tuple を作成
      tuple();

      // tuple(sequence) はシーケンスの要素で初期化した tuple を作成
      template <class T>
      explicit tuple(T const& sequence)
  };
}}

関数

make_tuple

template<class ...Args>
tuple make_tuple(Args const&... args)

object(a0),...object(an) 1 を組み合わせて新しいタプルオブジェクトを構築する。

using namespace boost::python;
tuple head_and_tail(object sequence)
{
    return make_tuple(sequence[0],sequence[-1]);
}
1

訳注 a0anargs の全要素。