[C++-sig] Re: Re: Compile failure with object in V2

Dave Hawkes daveh at cadlink.com
Sun Jul 14 17:16:52 CEST 2002


"David Abrahams" <david.abrahams at rcn.com> wrote in message
news:1cd801c22b2a$0b843630$6601a8c0 at boostconsulting.com...
> From: "Dave Hawkes" <daveh at cadlink.com>
>
>
> >

> If you want to try something, try doing a search/replace which turns all
> instances of "c##" in boost/python/detail/returning.hpp into "zyx##".
>
> I've seen VC6 get confused about which entities a name should refer to
when
> there's more than one possibility before.
>

This made no difference :(

However by testing components of the constructor individually it would
appear that the compiler is objecting to passing the reference "x" to the
object_initializer::get function. This can be worked around by passing a
pointer instead, which I don't think has any ultimate effect on effficiency.
You can see the small change I made to the code fragment below.

Dave Hawkes


  class object : public object_base
  {
   public:
      // default constructor creates a None object
      object();
      // explicit conversion from any C++ object to Python
      template <class T>
      explicit object(T const& x)
          : object_base(object_initializer<is_proxy<T>::value>::get(
                      &x, detail::convertible<object const*>::check(&x)))
      {
      }

      // Throw error_already_set() if the handle is null.
      explicit object(handle<> const&);

   public: // implementation detail -- for internal use only
      explicit object(detail::borrowed_reference);
      explicit object(detail::new_reference);
  };

  //
  // object_initializer -- get the handle to construct the object with,
  // based on whether T is a proxy or derived from object
  //
  template <bool is_proxy = false>
  struct object_initializer
  {
      static PyObject*
      get(object const* x, detail::yes_convertible)
      {
          return python::incref(x->ptr());
      }

      template <class T>
      static PyObject*
      get(T const* x, detail::no_convertible)
      {
          return python::incref(converter::arg_to_python<T>(*x).get());
      }
  };

  template <>
  struct object_initializer<true>
  {
      template <class Policies>
      static PyObject*
      get(proxy<Policies> const* x, detail::no_convertible)
      {
          return python::incref(x->operator object().ptr());
      }
  };
}










More information about the Cplusplus-sig mailing list