diff --git a/include/boost/multiprecision/complex_adaptor.hpp b/include/boost/multiprecision/complex_adaptor.hpp index 2956e32e2..d5edd917f 100644 --- a/include/boost/multiprecision/complex_adaptor.hpp +++ b/include/boost/multiprecision/complex_adaptor.hpp @@ -192,6 +192,56 @@ struct complex_adaptor m_real.negate(); m_imag.negate(); } + + // + // Default precision: + // + static BOOST_MP_CXX14_CONSTEXPR unsigned default_precision() noexcept + { + return Backend::default_precision(); + } + static BOOST_MP_CXX14_CONSTEXPR void default_precision(unsigned digits10) + { + Backend::default_precision(digits10); + Backend::thread_default_precision(digits10); + } + static BOOST_MP_CXX14_CONSTEXPR unsigned thread_default_precision() noexcept + { + return Backend::thread_default_precision(); + } + static BOOST_MP_CXX14_CONSTEXPR void thread_default_precision(unsigned digits10) + { + Backend::thread_default_precision(digits10); + } + BOOST_MP_CXX14_CONSTEXPR unsigned precision() const noexcept + { + return m_real.precision(); + } + BOOST_MP_CXX14_CONSTEXPR void precision(unsigned digits10) + { + m_real.precision(digits10); + m_imag.precision(digits10); + } + // + // Variable precision options: + // + static constexpr variable_precision_options default_variable_precision_options()noexcept + { + return Backend::default_variable_precision_options(); + } + static constexpr variable_precision_options thread_default_variable_precision_options()noexcept + { + return Backend::thread_default_variable_precision_options(); + } + static BOOST_MP_CXX14_CONSTEXPR void default_variable_precision_options(variable_precision_options opts) + { + Backend::default_variable_precision_options(opts); + Backend::thread_default_variable_precision_options(opts); + } + static BOOST_MP_CXX14_CONSTEXPR void thread_default_variable_precision_options(variable_precision_options opts) + { + Backend::thread_default_variable_precision_options(opts); + } }; template diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 130244609..eb10eda48 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -1234,6 +1234,7 @@ test-suite misc : [ run git_issue_540.cpp ] [ run git_issue_573.cpp : : : msvc:-sdl ] [ run git_issue_576.cpp : : : [ check-target-builds ../config//has_float128 : TEST_FLOAT128 quadmath : ] ] + [ run git_issue_595.cpp : : : [ check-target-builds ../config//has_mpfr : gmp mpfr : no ] ] [ compile git_issue_98.cpp : [ check-target-builds ../config//has_float128 : TEST_FLOAT128 quadmath : ] [ check-target-builds ../config//has_gmp : TEST_GMP gmp : ] diff --git a/test/git_issue_595.cpp b/test/git_issue_595.cpp new file mode 100644 index 000000000..bb7f7de88 --- /dev/null +++ b/test/git_issue_595.cpp @@ -0,0 +1,46 @@ +/////////////////////////////////////////////////////////////////////////////// +// Copyright 2023 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include "test.hpp" + +template +void test() +{ + T val; + unsigned n = T::default_precision(); + T::default_precision(n); + n = T::thread_default_precision(); + T::thread_default_precision(n); + n = val.precision(); + val.precision(n); +} + + + +int main() +{ + using namespace boost::multiprecision; + + test(); + + using c = number, et_on>; + + test(); + + using l = number, et_on>; + + test(); + + using d = number, et_on>; + + test(); + + return boost::report_errors(); +}