Topic: Memory-less constants
Author: dwalker07@snet.net (Daryle Walker)
Date: Mon, 23 Aug 2004 00:49:53 GMT Raw View
We use compile-time typed constants like
class MyType
{
static int const x = 7;
float y[ x ];
public:
//...
};
The problem is that "MyType::x" should need to have a separate
definition somewhere. I think there are efforts around here to optimize
that need away. Maybe we should go the other way: use the above method
to ensure storage, and use a new construct to specify compile-time
constants (that never get stored).
constant xx = 8;
constant yy = "Hi there";
We can insist on typing sometimes:
constant<float> zz = 7;
constant<MyEnum> aa = myFirstValue;
(What about arrays, unions, structures, classes?)
Just rambling....
--
Daryle Walker
Mac, Internet, and Video Game Junkie
dwalker07 AT snet DOT net
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: technews@kangaroologic.com ("Jonathan Turkanis")
Date: Mon, 23 Aug 2004 05:03:39 GMT Raw View
"Daryle Walker" <dwalker07@snet.net> wrote in message
news:dwalker07-D1C357.19100922082004@newsclstr01.news.prodigy.com...
> We use compile-time typed constants like
>
> class MyType
> {
> static int const x = 7;
>
> float y[ x ];
>
> public:
> //...
> };
>
> The problem is that "MyType::x" should need to have a separate
> definition somewhere. I think there are efforts around here to
optimize
> that need away.
This has already been done: see 3.2/2 of the second edition of the
standard
Jonathan
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]