[math_toolkit] ADL question

Hello, I haven't looked much at the math toolkit yet but I was interested in how it handled errors so I peeked at common_error_handling.hpp I see it explicitly qualifies each all to isfinite with (boost::math::isfinite)( value ). I assume this is to prevent macro expansion however this means that if a UDT is passed in the user is required to add their isfinite to the boost::math namespace instead of having it be reachable through ADL. Is this intentional? I think the following would work if it's not. using boost::math::isfinite; isfinite BOOST_PREVENT_MACRO_SUBSTITUTION( value ); I'm not sure if UDT support for this library has been considered in its design but I'm working to provide a fixed-point math library that I hope can be used as a real type just like float and double. I would like to be able to keep as much as possible in the library's namespace. Thanks, Michael Marcin

Michael Marcin wrote:
Hello,
I haven't looked much at the math toolkit yet but I was interested in how it handled errors so I peeked at common_error_handling.hpp
I see it explicitly qualifies each all to isfinite with (boost::math::isfinite)( value ).
I assume this is to prevent macro expansion however this means that if a UDT is passed in the user is required to add their isfinite to the boost::math namespace instead of having it be reachable through ADL.
Is this intentional? I think the following would work if it's not.
using boost::math::isfinite; isfinite BOOST_PREVENT_MACRO_SUBSTITUTION( value );
I'm not sure if UDT support for this library has been considered in its design but I'm working to provide a fixed-point math library that I hope can be used as a real type just like float and double. I would like to be able to keep as much as possible in the library's namespace.
Good points, but if we rely on ADL don't we get ambiguities between boost::math::isfinite and ::isfinite (when defined as a global function)? Thanks, John.

John Maddock wrote:
Michael Marcin wrote:
Hello,
I haven't looked much at the math toolkit yet but I was interested in how it handled errors so I peeked at common_error_handling.hpp
I see it explicitly qualifies each all to isfinite with (boost::math::isfinite)( value ).
I assume this is to prevent macro expansion however this means that if a UDT is passed in the user is required to add their isfinite to the boost::math namespace instead of having it be reachable through ADL.
Is this intentional? I think the following would work if it's not.
using boost::math::isfinite; isfinite BOOST_PREVENT_MACRO_SUBSTITUTION( value );
I'm not sure if UDT support for this library has been considered in its design but I'm working to provide a fixed-point math library that I hope can be used as a real type just like float and double. I would like to be able to keep as much as possible in the library's namespace.
Good points, but if we rely on ADL don't we get ambiguities between boost::math::isfinite and ::isfinite (when defined as a global function)?
IIRC the using declaration brings boost::math::isfinite into local scope and since the compiler finds a suitable function in this inner scope it doesn't bother to search broader scopes (like global scope). So I think this is OK. Thanks, Michael Marcin

Michael Marcin wrote:
IIRC the using declaration brings boost::math::isfinite into local scope and since the compiler finds a suitable function in this inner scope it doesn't bother to search broader scopes (like global scope).
So I think this is OK.
I'll experiment, but after I posted that message I realised that there is another easy-ish workaround as well, so this will get fixed before we release. John.
participants (2)
-
John Maddock
-
Michael Marcin