ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> cpp-sig
cpp-sig
Re: [C++-sig] extractors
by Ralf W. Grosse-Kunstleve other posts by this author
Jul 15 2002 4:14PM messages near this date
[C++-sig] extractors | [C++-sig] Building on Windows from CVS
--- David Abrahams <david.abrahams@[...].com>  wrote:
>      d. Ultimately, that means that if the overload succeds, but the
>  iterable contains the wrong kind of elements, the selected function itself
>  will appear (from the Python side) to throw an exception immediately. That
>  seems acceptable to me.

The tests that go with my prototype implementation of the sequence ->  container
converter include a test for these overloads:

  int boost_array_3(boost::array<double, 3>  const& a);
  int boost_array_4(boost::array<double, 4>  const& a);

    .def("boost_array", boost_array_3)
    .def("boost_array", boost_array_4)

For this to work as expected the convertible() test has to know the number of
elements in the sequence. Is this possible if the input sequence can only be
traversed once?

Ideas:

a. I could simply limit the boost::array converters to lists and tuples. In our
environment this would be fully sufficient.

b. Or, if the input Python object is a list or tuple I check the length.
Otherwise convertible() returns true and construct() throws an exception if the
sequence length is not compatible.

c. Extending the idea: if the input Python object is a list or tuple I check
both the length and the convertibility of each element. For any other sequence
convertible() returns true and construct() throws an exception if there is a
problem.

Ralf


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


_______________________________________________
C++-sig mailing list
C++-sig@[...].org
http://mail.python.org/mailman/listinfo/c++-sig
Thread:
David Abrahams
Ralf W. Grosse-Kunstleve
David Abrahams

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved