Btw., here's a prototype of a utility for pretty printing of
tuple types. It might come in handy as a generic implementation
of type_name() for tuples, as a replacement for the handful of
hardwired tuple types we have there.
#include <cstring>
#include <tuple>
template <class T> const char* type_name () { return "???"; }
template <> const char* type_name<char>() { return "char"; }
template <> const char* type_name<short>() { return "short"; }
template <> const char* type_name<int>() { return "int"; }
// ...
template <class ...Types>
struct Name;
template <class T>
struct Name<T> {
static void append (char* buf) {
std::strcat (buf, type_name<T>());
}
};
template <>
struct Name<> {
static void append (char*) { }
};
template <class T, class ...Types>
struct Name<T, Types...> {
static void append (char *buf) {
std::strcat (buf, type_name<T>());
std::strcat (buf, ", ");
Name<Types...>::append (buf);
}
};
template <class ...Types>
char* name (std::tuple<Types...>*)
{
static char buf [256];
std::strcpy (buf, "tuple<");
Name<Types...>::append (buf);
std::strcat (buf, ">");
return buf;
}
Eric Lemings wrote:
-----Original Message-----
From: Martin Sebor [mailto:[EMAIL PROTECTED] On Behalf Of Martin Sebor
Sent: Friday, July 11, 2008 1:06 PM
To: [email protected]
Subject: Re: structure of tuple tests ([Fwd: Re: svn commit:
r675044 - in /stdcxx/branches/4.3.x: include/rw/_tuple.h
include/tuple tests/utilities/20.tuple.cnstr.cpp
tests/utilities/20.tuple.creation.cpp
tests/utilities/20.tuple.h tests/utilities/20.tuple.helpers
...
You might want to consider extending the UserClass class defined
in tests/include/rw_value.h, or at least borrowing code or ideas
from it.
I generalized the overall test pattern for tuples with the latest
revision 677458. It might not be exactly what you're after but I
think it's much closer than the previous version. For instance, I
lot of the tests could be wrapped in TEST() function macros.
Have a look if you find time.
Brad.