[C++-sig] Implicit constructors?

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Sat Jul 27 00:29:48 CEST 2002


--- David Abrahams <dave at boost-consulting.com> wrote:
> Yep. This is part of the reason we need a more-sophisticated overload
> resolution mechanism.
> However, remember that a const& argument matches rvalue converters. If you
> only want to match converters which succeed when an actual shared<Element>
> is contained within the Python object (lvalue converters), have your
> function take a shared<Element> const* or a shared<Element>& parameter.

I decided that this was getting way too murky. Therefore I changed the
seq->container converter to only accept Python lists, tuples and iterators. So
if you have some custom type, you have to pass iter(myobj) (in Python) instead
of the bare myobj. As a side-affect, the C++ code looks more pleasing now.

With this change and the copy-contructor trick things are working very nicely
with tru64 cxx 6.5 and gcc 3.0.4.

If anybody would like to have a look at the latest version of my Python wrapper
for the shared<> C++ container including automatic conversions from Python
lists, tuples and iterators (the wrapper could easily be adapted for
std::vector<>), here it is:

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/cctbx/cctbx/include/cctbx/array_family/shared_bpl.h?rev=1.4.2.4&only_with_tag=boost_python_v2_transition&content-type=text/vnd.viewcvs-markup

Ralf


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




More information about the Cplusplus-sig mailing list