|
Boost : |
Subject: Re: [boost] tuple<T,T,...> generator meta-function
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2009-10-23 09:16:08
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Friday 23 October 2009, Emre Turkay wrote:
> Hi folks,
>
> How can I do this in a better way?
>
> template <typename T, size_t N>
> struct make_tuple { };
>
> template <typename T>
> struct make_tuple<T, 1>
> {
> typedef boost::tuple<T> type;
> };
>
> template <typename T>
> struct make_tuple<T, 2>
> {
> typedef boost::tuple<T, T> type;
> };
>
If you have a c++0x compiler, you could define it recursively using variadic
templates. Otherwise, you could use Boost.Preprocessor.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAkrhrJkACgkQ5vihyNWuA4WOIQCeLggKvmAlYFzRsYWXSwiqd5tx
JJkAnikG50kPcfpo86Whp8UVZoGWZ9yF
=BXDu
-----END PGP SIGNATURE-----
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk