~yade-dev/yade/0.80

« back to all changes in this revision

Viewing changes to extra/boost_python_len.hpp

  • Committer: Anton Gladky
  • Date: 2012-05-02 21:50:42 UTC
  • Revision ID: gladky.anton@gmail.com-20120502215042-v1fa9r65usqe7kfk
0.80.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#pragma once
 
2
#include<boost/python/object.hpp>
 
3
#include<boost/version.hpp>
 
4
#if BOOST_VERSION<103400
 
5
        // taken from boost-1.34/python/object.hpp
 
6
 
 
7
        // Copyright David Abrahams 2002.
 
8
        // Distributed under the Boost Software License, Version 1.0. (See
 
9
        // accompanying file LICENSE_1_0.txt or copy at
 
10
        // http://www.boost.org/LICENSE_1_0.txt)
 
11
 
 
12
        namespace boost { namespace python {
 
13
 
 
14
                 inline ssize_t len(object const& obj)
 
15
                 {
 
16
                          ssize_t result = PyObject_Length(obj.ptr());
 
17
                          if (PyErr_Occurred()) throw_error_already_set();
 
18
                          return result;
 
19
                 }
 
20
 
 
21
        }} // namespace boost::python
 
22
#endif // BOOST_VERSION<103400