 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
laurentoget@gmail.com Guest
|
Posted: Tue Nov 07, 2006 10:10 am Post subject: hide zero size array with Template Meta Programming |
|
|
I have a template class which contains a buffer
char buffer[f(T,...)];
whose size is a function of the template parameters. This works very
well until the template is instanciated for a set of parameters for
which f(T,...) is 0. compilers do not like zero size arrays.
I have a feeling there should be a way to use template metaprogramming
so that the buffer is only there when f(T,...) is >0, but do not know
where to start.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
James Kanze Guest
|
Posted: Wed Nov 08, 2006 10:10 am Post subject: Re: hide zero size array with Template Meta Programming |
|
|
Frederick Gotham wrote:
| Quote: | laurentoget (AT) gmail (DOT) com:
char buffer[f(T,...)];
Forgive me, but what the hell is that? At first glance, it looks like the
definition of an array whose dimension is determined by a function
declaration which lacks a return type. . .
|
Presumably, he is using f() in a mathematical sense here, that
the size is a function of the template parameters (and possibly
other things), and he doesn't mean that the f() is a C++
function. Traditionally, T is the name of the first template
type parameter, and you cannot call a C++ with a template type
parameter as an argument.
--
James Kanze (GABI Software) email:james.kanze (AT) gmail (DOT) com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
laurentoget@gmail.com Guest
|
Posted: Thu Nov 09, 2006 5:05 pm Post subject: Re: hide zero size array with Template Meta Programming |
|
|
James Kanze wrote:
| Quote: | Frederick Gotham wrote:
laurentoget (AT) gmail (DOT) com:
char buffer[f(T,...)];
Forgive me, but what the hell is that? At first glance, it looks like the
definition of an array whose dimension is determined by a function
declaration which lacks a return type. . .
Presumably, he is using f() in a mathematical sense here, that
the size is a function of the template parameters (and possibly
other things), and he doesn't mean that the f() is a C++
function. Traditionally, T is the name of the first template
type parameter, and you cannot call a C++ with a template type
parameter as an argument.
|
exactly,
merci, James,
Laurent
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|