Not inherently, but you could use your own template typedefs:
template<int count, typename T> struct uniform_tuple;
template<typename T> struct uniform_tuple<2,T> { typedef
boost::tuple<T,T> type; };
template<typename T> struct uniform_tuple<3,T> { typedef
boost::tuple<T,T,T> type; };
template<typename T> struct uniform_tuple<4,T> { typedef
boost::tuple<T,T,T,T> type; };
// etc.
Then you use it like:
uniform_tuple<3,double>::type t;
You could play with Boost's MPL type lists and such to make it more
generic and have the preprocessor generate the redundant code, but
that may be overkill for what you want to do (not to mention beyond
the scope of this group, unlike tuple talk). Also the next version of
the standard will make template typedefs of thing a little prettier,
but you'll have to live with the ugliness for now.
Cheers! --M
Just by coincidence I had just written the following code. It doesn't
help the OP because it uses C++0X features (variadic templates). So
this is just a tantalizing peek at the future as opposed to genuine
help. :-\ But I thought it might be interesting nonetheless.
template <class Tuple, class U, std::size_t N> struct
make_array_imp;
template <class ...Up, class U>
struct make_array_imp<std::tuple<Up...>, U, 0>
{
typedef std::tuple<Up...> type;
};
template <class ...Up, class U, std::size_t N>
struct make_array_imp<std::tuple<Up...>, U, N>
{
typedef typename make_array_imp<std::tuple<Up..., U>, U,
N-1>::type type;
};
template <class U, std::size_t N>
struct make_array
{
typedef typename make_array_imp<std::tuple<>, U, N>::type
type;
};
typedef typename make_array<T, 3>::type array; // tuple<T, T, T>
-Howard