On Wed, Sep 19, 2012 at 6:11 PM, Lou godio <lgod...@gmail.com> wrote:
> Dave,
> What's your current view on Inline::CPP support for C++11 tuples ??

Tuples are really just a new STL container that take advantage of the
fact that C++11 implements variadic templates.  So essentially the
same rule applies to tuples as to any other C++ object: All data types
need to be represented with a typemap.

The default typemap understands POD types (Plain Old Data): int, long,
short, char, double, float, etc.  The one aggregate container that
Perl's default typemaps handle is the null-terminated array of chars
(C-Strings).

When you use a more complex object type, Perl needs a type map for
that type that tells Perl how to put values into it, and how to
extract values from it.  This is done by adding your own typemaps.
This is why we usually don't see Inline::CPP functions passing vectors
back and forth, for example; there's no "vector" typemap.  No
"multi-map" typemap, etc.  There certainly could be.  But there's one
other problem.  Those containers can hold any data type.  So you would
also need to deal with the genericity (is that a word?) of the STL
containers within your type map.  ...a bunch of meta-programming that
keeps track of whether it's a vector<char> or a vector<pair<char,int>
>, or what.  Way too much work.

The easiest approach is to create accessors for your classes that
shield Perl from the details about the container type.  Don't return a
vector.  Return an iterator, or return a value, or return a list, or a
Perl container.

So the short answer is feel free to use Tuples internally, and expose
to Perl either Perl containers or plain old data types, just as you
would do with vectors, maps, etc.

I hope this helps.

Dave


-- 

David Oswald
daosw...@gmail.com

Reply via email to