
On 16/04/2023 19:52, Gero Peterhoff via Boost wrote:
Hello John, * problem description The functions of boost::multiprecision are not available in std, e.g. template <typename type> Type foo(const Type x) noexcept { return std::sin(x) * 42; }
using A = double; A a = foo(A(23)); // ok
using B = boost::multiprecision::cpp_bin_float_oct; B b = foo(B(23)); // error
As a workaround you currently have to write template <typename Type> Type bar(const Type x) noexcept { using ::std::sin; using ::boost::multiprecision::sin; return sin(x) * 42; }
using A = double; A a = bar(A(23)); // ok
using B = boost::multiprecision::cpp_bin_float_oct; B b = bar(B(23)); // ok
This contradicts the template idea and is time-consuming/error-prone.
We are not allowed to overload anything in namespace std, so the correct incantation for any generic code is: template <typename Type> Type bar(const Type x) // cannot be noexcept if used in multiprecision case { using ::std::sin; return sin(x) * 42; // potentially found via ADL } John.