1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/python/back_reference.hpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,102 @@
1.4 +// Copyright David Abrahams 2002.
1.5 +// Distributed under the Boost Software License, Version 1.0. (See
1.6 +// accompanying file LICENSE_1_0.txt or copy at
1.7 +// http://www.boost.org/LICENSE_1_0.txt)
1.8 +#ifndef BACK_REFERENCE_DWA2002510_HPP
1.9 +# define BACK_REFERENCE_DWA2002510_HPP
1.10 +
1.11 +# include <boost/python/detail/prefix.hpp>
1.12 +
1.13 +# include <boost/python/object_fwd.hpp>
1.14 +# include <boost/python/detail/dependent.hpp>
1.15 +# include <boost/python/detail/raw_pyobject.hpp>
1.16 +
1.17 +namespace boost { namespace python {
1.18 +
1.19 +template <class T>
1.20 +struct back_reference
1.21 +{
1.22 + private: // types
1.23 + typedef typename detail::dependent<object,T>::type source_t;
1.24 + public:
1.25 + typedef T type;
1.26 +
1.27 + back_reference(PyObject*, T);
1.28 + source_t const& source() const;
1.29 + T get() const;
1.30 + private:
1.31 + source_t m_source;
1.32 + T m_value;
1.33 +};
1.34 +
1.35 +# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
1.36 +template<typename T>
1.37 +class is_back_reference
1.38 +{
1.39 + public:
1.40 + BOOST_STATIC_CONSTANT(bool, value = false);
1.41 +};
1.42 +
1.43 +template<typename T>
1.44 +class is_back_reference<back_reference<T> >
1.45 +{
1.46 + public:
1.47 + BOOST_STATIC_CONSTANT(bool, value = true);
1.48 +};
1.49 +
1.50 +# else // no partial specialization
1.51 +
1.52 +}} // namespace boost::python
1.53 +
1.54 +#include <boost/type.hpp>
1.55 +
1.56 +namespace boost { namespace python {
1.57 +
1.58 +namespace detail
1.59 +{
1.60 + typedef char (&yes_back_reference_t)[1];
1.61 + typedef char (&no_back_reference_t)[2];
1.62 +
1.63 + no_back_reference_t is_back_reference_test(...);
1.64 +
1.65 + template<typename T>
1.66 + yes_back_reference_t is_back_reference_test(boost::type< back_reference<T> >);
1.67 +}
1.68 +
1.69 +template<typename T>
1.70 +class is_back_reference
1.71 +{
1.72 + public:
1.73 + BOOST_STATIC_CONSTANT(
1.74 + bool, value = (
1.75 + sizeof(detail::is_back_reference_test(boost::type<T>()))
1.76 + == sizeof(detail::yes_back_reference_t)));
1.77 +};
1.78 +
1.79 +# endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
1.80 +
1.81 +//
1.82 +// implementations
1.83 +//
1.84 +template <class T>
1.85 +back_reference<T>::back_reference(PyObject* p, T x)
1.86 + : m_source(detail::borrowed_reference(p))
1.87 + , m_value(x)
1.88 +{
1.89 +}
1.90 +
1.91 +template <class T>
1.92 +typename back_reference<T>::source_t const& back_reference<T>::source() const
1.93 +{
1.94 + return m_source;
1.95 +}
1.96 +
1.97 +template <class T>
1.98 +T back_reference<T>::get() const
1.99 +{
1.100 + return m_value;
1.101 +}
1.102 +
1.103 +}} // namespace boost::python
1.104 +
1.105 +#endif // BACK_REFERENCE_DWA2002510_HPP