diff --git a/include/boost/math/differentiation/autodiff.hpp b/include/boost/math/differentiation/autodiff.hpp index 32c7cae317..454c7f825c 100644 --- a/include/boost/math/differentiation/autodiff.hpp +++ b/include/boost/math/differentiation/autodiff.hpp @@ -393,6 +393,12 @@ class fvar { template friend std::ostream& operator<<(std::ostream&, fvar const&); + template + friend std::istream& operator>>(std::istream&, fvar &); + + template + friend std::wistream& operator>>(std::wistream&, fvar &); + // C++11 Compatibility #ifdef BOOST_NO_CXX17_IF_CONSTEXPR template @@ -1730,6 +1736,22 @@ std::ostream& operator<<(std::ostream& out, fvar const& cr) { return out << ')'; } +template +std::istream& operator>>(std::istream& in, fvar & cr) { + in >> cr.v.front(); + BOOST_IF_CONSTEXPR (0 < Order) + std::fill(cr.v.begin()+1, cr.v.end(), static_cast(0)); + return in; +} + +template +std::wistream& operator>>(std::wistream& in, fvar & cr) { + in >> cr.v.front(); + BOOST_IF_CONSTEXPR (0 < Order) + std::fill(cr.v.begin()+1, cr.v.end(), static_cast(0)); + return in; +} + // Additional functions template