Just a quick heads-up that I've added a type for generic tuples to the codebase -- Inkscape::Util::Tuple.
It consists of a simple struct template and a constructor function template. Tuples may contain up to six elements of arbitrary types.
For example, a type for a two-element tuple containing an int and a char const * would be:
Tuple<int, char const *> blah;
Its constructor may optionally take initial values for its members:
Tuple<int, char const *> blah(1, "foo");
The first member is named a, the second b, and so on:
cout << blah.a /* int */ << blah.b /* string */ << endl;
Also, for creating anonymous tuple values, there is a convenient constructor function which infers the types for you:
tuple(5, "testing").b /* string "testing" */
To use tuples, #include "util/tuple.h".
n.b. employ 'using' if you don't want to have to spell out Inkscape::Util::Tuple and Inkscape::Util::tuple -- e.g.:
using Inkscape::Util::Tuple; using Inkscape::Util::tuple;
...but please keep 'using' out of header files! Inside class bodies is OK though.
Just thought you all might find tuples useful..
-mental
participants (1)
-
MenTaLguY