|
Boost : |
From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2003-06-22 15:01:19
>From: "Daniel Frey" <d.frey_at_[hidden]>
> On Sun, 22 Jun 2003 03:32:52 +0200, Terje Slettebø wrote:
> >
> > --- 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; }
> >
> > --- 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.
Ok. So maybe an extra level of indirection, as in your code (and
Kenniston's) may be preferable. I was wondering what was the point with it.
:)
Another thing, are the ADD_OPERATOR macro in your code necessary? It
compiles fine without it on Intel C++ 7.1.
> Also, I'm not sure whether it's standard compliant code.
I think it is. It specialises a member. What could be the problem with this?
As you say, errors are caught at link time.
Regards,
Terje
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk