diff --git a/doc/v2/object.html b/doc/v2/object.html index 1f47a075..40798e8e 100644 --- a/doc/v2/object.html +++ b/doc/v2/object.html @@ -183,11 +183,16 @@
binary operations
assignment operations
+
operators
+ +
+
len()
+
Example
@@ -918,16 +923,36 @@ object sum_items(object seq) result += seq[i]; return result; } + + +

len()

+
+inline long len(object const& obj);
+
+ +
+
Effects: PyObject_Length(obj.ptr())
+
Returns: len() of object.
+
+ +

Example

+ Python code: +
+len(obj)
+
+ C++ version: +
+len(obj);
 

Revised - 13 November, 2002 + 12 January, 2006

© Copyright Dave Abrahams 2002.

+ "../../../../people/dave_abrahams.htm">Dave Abrahams 2006.

diff --git a/include/boost/python/detail/api_placeholder.hpp b/include/boost/python/detail/api_placeholder.hpp index 61276a9f..5975a13b 100644 --- a/include/boost/python/detail/api_placeholder.hpp +++ b/include/boost/python/detail/api_placeholder.hpp @@ -2,17 +2,14 @@ // 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) + +// DEPRECATED HEADER (2006 Jan 12) +// Provided only for backward compatibility. +// The boost::python::len() function is now defined in object.hpp. + #ifndef BOOST_PYTHON_API_PLACE_HOLDER_HPP #define BOOST_PYTHON_API_PLACE_HOLDER_HPP -namespace boost { namespace python { - - inline long len(object const& obj) - { - long result = PyObject_Length(obj.ptr()); - if (PyErr_Occurred()) throw_error_already_set(); - return result; - } -}} // namespace boost::python +#include #endif // BOOST_PYTHON_API_PLACE_HOLDER_HPP diff --git a/include/boost/python/object.hpp b/include/boost/python/object.hpp index f6ee4661..677ffb42 100755 --- a/include/boost/python/object.hpp +++ b/include/boost/python/object.hpp @@ -13,4 +13,15 @@ # include # include +namespace boost { namespace python { + + inline long len(object const& obj) + { + long result = PyObject_Length(obj.ptr()); + if (PyErr_Occurred()) throw_error_already_set(); + return result; + } + +}} // namespace boost::python + #endif // OBJECT_DWA2002612_HPP diff --git a/src/object/enum.cpp b/src/object/enum.cpp index e319bd08..e0438ee1 100644 --- a/src/object/enum.cpp +++ b/src/object/enum.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include diff --git a/src/object/function.cpp b/src/object/function.cpp index 429fcbb1..653343b9 100644 --- a/src/object/function.cpp +++ b/src/object/function.cpp @@ -15,7 +15,6 @@ #include #include -#include #include #include diff --git a/src/object/pickle_support.cpp b/src/object/pickle_support.cpp index 4664eefd..897ee633 100644 --- a/src/object/pickle_support.cpp +++ b/src/object/pickle_support.cpp @@ -8,7 +8,6 @@ #include #include #include -#include namespace boost { namespace python { diff --git a/test/pickle2.cpp b/test/pickle2.cpp index ab4ad9c3..eb50cca3 100644 --- a/test/pickle2.cpp +++ b/test/pickle2.cpp @@ -27,7 +27,6 @@ #include #include #include -#include namespace { // Avoid cluttering the global namespace. diff --git a/test/pickle3.cpp b/test/pickle3.cpp index 95956733..cffcb9c0 100644 --- a/test/pickle3.cpp +++ b/test/pickle3.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include namespace { // Avoid cluttering the global namespace.