$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Daniel Frey (d.frey_at_[hidden])
Date: 2003-06-22 11:56:04
On Sun, 22 Jun 2003 03:32:52 +0200, Terje Slettebø wrote:
> Having considered Kenniston's and Daniel's approach, I wonder if it's
> possible to simplify it. The following uses the same approach as
> Daniel's - specialisation, as it allows it to be done with just one
> class for each constant, and nothing else:
>
> --- Start ---
>
> #include <iostream>
>
> #define BOOST_DEFINE_MATH_CONSTANT(name)\ const struct name##_type\ {\
> name##_type() {}\
> template<class T>\
> operator T() const;\
> } name;
>
> #define BOOST_MATH_CONSTANT_VALUE(name, type, value)\ template<>\
> name##_type::operator type() const { return value; }
>
> [snip]
>
> --- End ---
>
> My question is: Is there any reason why it can't be done this simple?
Yes. AFAICS wrong use of your constants with unsupported types is only
cought at link-time, not at compile-time. This is IMHO a big problem, big
enough to reject this approach. Also, I'm not sure whether it's standard
compliant code.
Regards, Daniel