[C++-sig] std_map_indexing_suite
troy d. straszheim
troy at resophonic.com
Wed Apr 1 21:17:02 CEST 2009
troy d. straszheim wrote:
> I'm wondering why the current map_indexing_suite is the way it is. Is
> there any reason not to enhance it to support now standard methods like
> keys(), values(), popitem() and the like?
A colleague and I have been working on an indexing suite that gives a
wrapped std::map essentially the same interface as a python dict. The
main reason is that the minimal interface of the current
map_indexing_suite has the effect of making the python-wrapper
abstraction 'leaky'... that is, beginners who know nothing of C++
naturally ask why they can do these things with a dict 'd':
d = dict([('one',1), ('two', 2)])
for k,v in d.iteritems():
print k, v*2
d.keys()
d.values()
d.items()
d.iterkeys() (and a few others)
but they cannot do so with a python class that is a wrapped
std::map<string, double>... This is a big hassle for the architect who
wants to be able to allow some of the userbase to remain completely
ignorant of the C++ side of things.
Any interest in getting this documented and in to the library?
Current version attached. May still have some bugs and/or need some
refactoring.
-t
-------------- next part --------------
A non-text attachment was scrubbed...
Name: std_map_indexing_suite.hpp
Type: text/x-c++hdr
Size: 16402 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20090401/33de6ed7/attachment.hpp>
More information about the Cplusplus-sig
mailing list