From: John Maddock (john_at_[hidden])
Date: 2007-05-16 13:36:10
Paul A Bristow wrote:
> If we want it to fail at compile time, IMO it MUST be an option
> becaue there are occasions when it is vital to be able treat all
> distributions alike. A typical case is our C# .NET (cue hisses and
> boos) 'applet' to calculate distribution parameters - for any
> distribution chosen from a dropdown. (This useful program will be
> posted somewhere soon).
Two other options: we could remove the definitions of accessor functions
that are undefined for that distribution, and then add our own private
"catch all" versions when we need them. Or we could add the "catch all"
versions to a separate namespace, and users could bring them into scope when
needed. Do we have customised (as in meaningful and distribution specific)
error messages for the current functions though? If so we should try and
> So to provide an option, a macro seems sensible, perhaps
The consensus seems to be for making compiler errors the default, so maybe
BOOST_MATH_DEFINE_ALL_ACCESSORS to make them available regardless of whether
they are mathematically defined for the distribution.
> BOOST_STATIC_ASSERT(false); has been one way of providing a compile
> time trap and fails with a rather long message, although clicking on
> the 1st line goes straight to the source code above, so it soon
> becomes pretty clear.
It would have to be BOOST_STATIC_ASSERT(sizeof(T) == 0) as some compilers
realise that BOOST_STATIC_ASSERT(false) will always fail and issue a
diagnostic irrespective of whether the template is instantiated.
> For MSVC at least one can use the #error pragma thus
> #ifdef BOOST_MATH_COMPILE_FAIL_IF_UNDEFINED
> # ifdef BOOST_MSVC
> # error Mean of the Cauchy distribution is undefined!
> # else
> # endif
> and this produces the rather more explicit message:
> : fatal error C1189: #error : Mean of the Cauchy distribution is
Surely that just gives an error whenever you include the header?
Or we could simply not provide the definitions of these functions at all:
but then the error messages might be rather cryptic?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk