[C++-sig] Implicit constructors?

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Fri Jul 26 20:31:00 CEST 2002


--- David Abrahams <dave at boost-consulting.com> wrote:
> I think if you def() the copy constructor it should work automatically
> (though it could be more efficient). Does that help?

def()'ing the copy constructor works. However, registering the
python_sequence_to_container converter for a type that is also exposed with
class_<> leads to confusing behavior. I have not spent enough time to come to a
conlusion. To explain what I've found out so far:

"shared" is a reference-counted array type.

a = shared.double((1,2,3)) # works using the copy-constructor trick
a.as_tuple() # confusing behavior

    PyObject* // BPL_FUTURE return tuple
    as_tuple(const shared<ElementType>& v)
    {
      return bpl_utils::container_to_tuple<shared<ElementType> >::convert(v);
    }

Apparently overload resolution calls the sequence_to_container converter when
matching "a" (Python) to the as_tuple() (C++) argument. My current
implementation of the seq-container converter is so general that it decides "a"
can be converted to an iterator and then goes ahead and constructs a new
shared<ElementType> . Could this interpretation be right so far?

Ralf


__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com




More information about the Cplusplus-sig mailing list