long.qbk 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. [section boost/python/long.hpp]
  2. [section Introduction]
  3. Exposes a [link concepts.objectwrapper.typewrapper_concept_requirements TypeWrapper] for the Python [@http://www.python.org/doc/current/lib/typesnumeric.html long] integer type.
  4. [endsect]
  5. [section Class `long_`]
  6. Exposes the [@http://www.python.org/doc/current/lib/typesnumeric.html numeric type protocol] of Python's built-in `long` type. The semantics of the constructors and member functions defined below can be fully understood by reading the [link concepts.objectwrapper.typewrapper_concept_requirements TypeWrapper] concept definition. Since `long_` is publicly derived from [link object_wrappers.boost_python_object_hpp.class_object `object`], the public `object` interface applies to `long_` instances as well.
  7. ``
  8. namespace boost { namespace python
  9. {
  10. class long_ : public object
  11. {
  12. public:
  13. long_(); // new long_
  14. template <class T>
  15. explicit long_(T const& rhs);
  16. template <class T, class U>
  17. long_(T const& rhs, U const& base);
  18. };
  19. }}
  20. ``
  21. [endsect]
  22. [section Example]
  23. ``
  24. namespace python = boost::python;
  25. // compute a factorial without overflowing
  26. python::long_ fact(long n)
  27. {
  28. if (n == 0)
  29. return python::long_(1);
  30. else
  31. return n * fact(n - 1);
  32. }
  33. ``
  34. [endsect]
  35. [endsect]