|
21 | 21 | #include <boost/math/tools/real_cast.hpp> |
22 | 22 | #include <boost/math/special_functions/binomial.hpp> |
23 | 23 | #include <boost/operators.hpp> |
| 24 | +#include <boost/type_traits/is_convertible.hpp> |
24 | 25 |
|
25 | 26 | #include <vector> |
26 | 27 | #include <ostream> |
@@ -377,15 +378,17 @@ class polynomial : ordered_euclidean_ring_operators< polynomial<T> > |
377 | 378 | } |
378 | 379 |
|
379 | 380 | template <class U> |
380 | | - polynomial& operator /=(const U& value) |
| 381 | + BOOST_DEDUCED_TYPENAME enable_if<boost::is_convertible<U,T>, polynomial >::type& |
| 382 | + operator /=(const U& value) |
381 | 383 | { |
382 | 384 | division(value); |
383 | 385 | normalize(); |
384 | 386 | return *this; |
385 | 387 | } |
386 | 388 |
|
387 | 389 | template <class U> |
388 | | - polynomial& operator %=(const U& /*value*/) |
| 390 | + BOOST_DEDUCED_TYPENAME enable_if<boost::is_convertible<U,T>, polynomial >::type& |
| 391 | + operator %=(const U& /*value*/) |
389 | 392 | { |
390 | 393 | // We can always divide by a scalar, so there is no remainder: |
391 | 394 | *this = zero_element(std::multiplies<polynomial>()); |
@@ -431,27 +434,12 @@ class polynomial : ordered_euclidean_ring_operators< polynomial<T> > |
431 | 434 | return *this; |
432 | 435 | } |
433 | 436 |
|
434 | | - template <typename U> |
435 | | - polynomial& operator /=(const polynomial<U>& value) |
436 | | - { |
437 | | - *this = quotient_remainder(*this, polynomial(value)).first; |
438 | | - return *this; |
439 | | - } |
440 | | - |
441 | 437 | polynomial& operator %=(const polynomial& value) |
442 | 438 | { |
443 | 439 | *this = quotient_remainder(*this, value).second; |
444 | 440 | return *this; |
445 | 441 | } |
446 | 442 |
|
447 | | - |
448 | | - template <typename U> |
449 | | - polynomial& operator %=(const polynomial<U>& value) |
450 | | - { |
451 | | - *this = quotient_remainder(*this, polynomial(value)).second; |
452 | | - return *this; |
453 | | - } |
454 | | - |
455 | 443 | template <typename U> |
456 | 444 | polynomial& operator >>=(U const &n) |
457 | 445 | { |
|
0 commit comments