|
Boost Users : |
From: Robert Dailey (rcdailey_at_[hidden])
Date: 2008-03-31 12:57:46
Hi,
I realize that C++03 will not permit functions to evaluate down to
compile-time constants. However, I cannot wait until C++0x for this feature.
So, I'm hoping that Boost will allow a temporary solution. Consider the
following structure:
static struct nullptr_t
{
template< typename t_type >
operator t_type*() { return 0; }
} nullptr;
The compiler has everything it needs to turn this code into a single
integral constant value. So, if I do the following:
int* foo;
if( foo == nullptr )
{
}
Then it should evaluate down to:
int* foo;
if( foo == 0 )
{
}
Is there any way to provide this behavior in Boost? I would like to avoid
altering the actual design if possible. Perhaps this actually *does*
evaluate to a constant and the problem is that I'm actually unaware of some
specific rule that I didn't find in the C++03 standard. Thanks.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net