2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-19 16:32:16 +00:00
Files
python/test/upcast.cpp
2025-11-03 08:40:38 -05:00

20 lines
546 B
C++

// Copyright David Abrahams 2002.
// 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)
#include <boost/python/cast.hpp>
#include <boost/detail/lightweight_test.hpp>
struct X { long x; };
struct Y : X, PyObject {};
int main()
{
PyTypeObject o;
Y y;
BOOST_TEST(boost::python::upcast<PyObject>(&o) == reinterpret_cast<PyObject*>(&o));
BOOST_TEST(boost::python::upcast<PyObject>(&y) == &y);
return boost::report_errors();
}