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 _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost