[C++-sig] make_tuple()?

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Sat Jul 20 03:37:06 CEST 2002


--- David Abrahams <david.abrahams at rcn.com> wrote:
> > return handle<>(borrowed(tuple(result).ptr())).release();
> 
> Really? That's better than make_tuple(a, b, c)?

Yes, because I had to make tuples three times. The append() solution really is
better in my context.
(But you are right in your suspicion that my first motivation to start looking
for alternative solutions was being scared by the prospect of having to deal
with the preprocessor library.)

> You can always do:
> 
>     incref(tuple(result).ptr())
> 
> Doesn't that suit?

Yes, thanks! I will put my patch in the attic for the time being. (But I must
add that this solution is even more low level than the hdl() approach; I was
hoping that I can completely forget about incref and decref.)

> > T* handle<T>::ptr() const;
> 
> Understood, but I'm not really sure I want to make them look the same.

Sigh.

On to the next question. I am wondering about the error handling approaches.
How does

  object state;
  tuple(state);

behave if state is not a tuple?

How do you envision api function such as len(object()) to behave if a Python
exception is raised? Should it be more like

    int len(object const& obj)
    {
        return PyObject_Length(obj.ptr());
    }

or

    int len(object const& obj)
    {
        int result = PyObject_Length(obj.ptr());
        if (PyErr_Occurred()) boost::python::throw_error_already_set();
        return result;
    }

Is there a firm plan already?

Ralf


__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com





More information about the Cplusplus-sig mailing list