comparison DEPENDENCIES/generic/include/boost/multiprecision/number.hpp @ 101:c530137014c0

Update Boost headers (1.58.0)
author Chris Cannam
date Mon, 07 Sep 2015 11:12:49 +0100
parents 2665513ce2d3
children
comparison
equal deleted inserted replaced
100:793467b5e61c 101:c530137014c0
39 { 39 {
40 typedef number<Backend, ExpressionTemplates> self_type; 40 typedef number<Backend, ExpressionTemplates> self_type;
41 public: 41 public:
42 typedef Backend backend_type; 42 typedef Backend backend_type;
43 BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number() BOOST_NOEXCEPT_IF(noexcept(Backend())) {} 43 BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number() BOOST_NOEXCEPT_IF(noexcept(Backend())) {}
44 BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(const number& e) BOOST_NOEXCEPT_IF(noexcept(Backend(static_cast<const Backend&>(std::declval<Backend>())))) : m_backend(e.m_backend){} 44 BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(const number& e) BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval<Backend const&>()))) : m_backend(e.m_backend){}
45 template <class V> 45 template <class V>
46 BOOST_MP_FORCEINLINE number(const V& v, typename boost::enable_if_c< 46 BOOST_MP_FORCEINLINE number(const V& v, typename boost::enable_if_c<
47 (boost::is_arithmetic<V>::value || is_same<std::string, V>::value || is_convertible<V, const char*>::value) 47 (boost::is_arithmetic<V>::value || is_same<std::string, V>::value || is_convertible<V, const char*>::value)
48 && !is_convertible<typename detail::canonical<V, Backend>::type, Backend>::value 48 && !is_convertible<typename detail::canonical<V, Backend>::type, Backend>::value
49 && !detail::is_restricted_conversion<typename detail::canonical<V, Backend>::type, Backend>::value 49 && !detail::is_restricted_conversion<typename detail::canonical<V, Backend>::type, Backend>::value
53 } 53 }
54 template <class V> 54 template <class V>
55 BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(const V& v, typename boost::enable_if_c< 55 BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(const V& v, typename boost::enable_if_c<
56 is_convertible<typename detail::canonical<V, Backend>::type, Backend>::value 56 is_convertible<typename detail::canonical<V, Backend>::type, Backend>::value
57 && !detail::is_restricted_conversion<typename detail::canonical<V, Backend>::type, Backend>::value 57 && !detail::is_restricted_conversion<typename detail::canonical<V, Backend>::type, Backend>::value
58 >::type* = 0) 58 >::type* = 0)
59 #ifndef BOOST_INTEL
60 BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval<typename detail::canonical<V, Backend>::type const&>())))
61 #endif
59 : m_backend(canonical_value(v)) {} 62 : m_backend(canonical_value(v)) {}
60 BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(const number& e, unsigned digits10) 63 BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(const number& e, unsigned digits10)
64 BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval<Backend const&>(), std::declval<unsigned>())))
61 : m_backend(e.m_backend, digits10){} 65 : m_backend(e.m_backend, digits10){}
62 template <class V> 66 template <class V>
63 explicit BOOST_MP_FORCEINLINE number(const V& v, typename boost::enable_if_c< 67 explicit BOOST_MP_FORCEINLINE number(const V& v, typename boost::enable_if_c<
64 (boost::is_arithmetic<V>::value || is_same<std::string, V>::value || is_convertible<V, const char*>::value) 68 (boost::is_arithmetic<V>::value || is_same<std::string, V>::value || is_convertible<V, const char*>::value)
65 && !detail::is_explicitly_convertible<typename detail::canonical<V, Backend>::type, Backend>::value 69 && !detail::is_explicitly_convertible<typename detail::canonical<V, Backend>::type, Backend>::value
66 && detail::is_restricted_conversion<typename detail::canonical<V, Backend>::type, Backend>::value 70 && detail::is_restricted_conversion<typename detail::canonical<V, Backend>::type, Backend>::value
67 >::type* = 0) 71 >::type* = 0)
72 BOOST_NOEXCEPT_IF(noexcept(std::declval<Backend&>() = std::declval<typename detail::canonical<V, Backend>::type const&>()))
68 { 73 {
69 m_backend = canonical_value(v); 74 m_backend = canonical_value(v);
70 } 75 }
71 template <class V> 76 template <class V>
72 explicit BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(const V& v, typename boost::enable_if_c< 77 explicit BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(const V& v, typename boost::enable_if_c<
73 detail::is_explicitly_convertible<typename detail::canonical<V, Backend>::type, Backend>::value 78 detail::is_explicitly_convertible<typename detail::canonical<V, Backend>::type, Backend>::value
74 && (detail::is_restricted_conversion<typename detail::canonical<V, Backend>::type, Backend>::value 79 && (detail::is_restricted_conversion<typename detail::canonical<V, Backend>::type, Backend>::value
75 || !is_convertible<typename detail::canonical<V, Backend>::type, Backend>::value) 80 || !is_convertible<typename detail::canonical<V, Backend>::type, Backend>::value)
76 >::type* = 0) 81 >::type* = 0)
82 BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval<typename detail::canonical<V, Backend>::type const&>())))
77 : m_backend(canonical_value(v)) {} 83 : m_backend(canonical_value(v)) {}
78 /* 84 /*
79 // 85 //
80 // This conflicts with component based initialization (for rational and complex types) 86 // This conflicts with component based initialization (for rational and complex types)
81 // which is arguably more useful. Disabled for now. 87 // which is arguably more useful. Disabled for now.
87 m_backend = canonical_value(v); 93 m_backend = canonical_value(v);
88 } 94 }
89 */ 95 */
90 template<expression_template_option ET> 96 template<expression_template_option ET>
91 BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(const number<Backend, ET>& val) 97 BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(const number<Backend, ET>& val)
92 BOOST_NOEXCEPT_IF(noexcept(Backend(static_cast<const Backend&>(std::declval<Backend>())))) : m_backend(val.backend()) {} 98 BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval<Backend const&>()))) : m_backend(val.backend()) {}
93 99
94 template <class Other, expression_template_option ET> 100 template <class Other, expression_template_option ET>
95 BOOST_MP_FORCEINLINE number(const number<Other, ET>& val, 101 BOOST_MP_FORCEINLINE number(const number<Other, ET>& val,
96 typename boost::enable_if_c<(boost::is_convertible<Other, Backend>::value && !detail::is_restricted_conversion<Other, Backend>::value)>::type* = 0) 102 typename boost::enable_if_c<(boost::is_convertible<Other, Backend>::value && !detail::is_restricted_conversion<Other, Backend>::value)>::type* = 0)
97 BOOST_NOEXCEPT_IF(noexcept(Backend(static_cast<const Other&>(std::declval<Other>())))) 103 BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval<Other const&>())))
98 : m_backend(val.backend()) {} 104 : m_backend(val.backend()) {}
99 105
100 template <class Other, expression_template_option ET> 106 template <class Other, expression_template_option ET>
101 explicit number(const number<Other, ET>& val, typename boost::enable_if_c< 107 explicit number(const number<Other, ET>& val, typename boost::enable_if_c<
102 (!detail::is_explicitly_convertible<Other, Backend>::value) 108 (!detail::is_explicitly_convertible<Other, Backend>::value)
109 } 115 }
110 template <class Other, expression_template_option ET> 116 template <class Other, expression_template_option ET>
111 explicit BOOST_MP_FORCEINLINE number(const number<Other, ET>& val, typename boost::enable_if_c< 117 explicit BOOST_MP_FORCEINLINE number(const number<Other, ET>& val, typename boost::enable_if_c<
112 (detail::is_explicitly_convertible<Other, Backend>::value 118 (detail::is_explicitly_convertible<Other, Backend>::value
113 && (detail::is_restricted_conversion<Other, Backend>::value || !boost::is_convertible<Other, Backend>::value)) 119 && (detail::is_restricted_conversion<Other, Backend>::value || !boost::is_convertible<Other, Backend>::value))
114 >::type* = 0) BOOST_NOEXCEPT_IF(noexcept(Backend(static_cast<const Other&>(std::declval<Other>())))) 120 >::type* = 0) BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval<Other const&>())))
115 : m_backend(val.backend()) {} 121 : m_backend(val.backend()) {}
116 122
117 template <class V> 123 template <class V>
118 BOOST_MP_FORCEINLINE number(V v1, V v2, typename boost::enable_if<mpl::or_<boost::is_arithmetic<V>, is_same<std::string, V>, is_convertible<V, const char*> > >::type* = 0) 124 BOOST_MP_FORCEINLINE number(V v1, V v2, typename boost::enable_if<mpl::or_<boost::is_arithmetic<V>, is_same<std::string, V>, is_convertible<V, const char*> > >::type* = 0)
119 { 125 {
141 do_assign(e, tag_type()); 147 do_assign(e, tag_type());
142 return *this; 148 return *this;
143 } 149 }
144 150
145 BOOST_MP_FORCEINLINE number& operator=(const number& e) 151 BOOST_MP_FORCEINLINE number& operator=(const number& e)
146 BOOST_NOEXCEPT_IF(noexcept(std::declval<Backend>() = static_cast<const Backend&>(std::declval<Backend>()))) 152 BOOST_NOEXCEPT_IF(noexcept(std::declval<Backend&>() = std::declval<Backend const&>()))
147 { 153 {
148 m_backend = e.m_backend; 154 m_backend = e.m_backend;
149 return *this; 155 return *this;
150 } 156 }
151 157
152 template <class V> 158 template <class V>
153 BOOST_MP_FORCEINLINE typename boost::enable_if<is_convertible<V, self_type>, number<Backend, ExpressionTemplates>& >::type 159 BOOST_MP_FORCEINLINE typename boost::enable_if<is_convertible<V, self_type>, number<Backend, ExpressionTemplates>& >::type
154 operator=(const V& v) 160 operator=(const V& v)
155 BOOST_NOEXCEPT_IF(noexcept(std::declval<Backend>() = static_cast<typename boost::multiprecision::detail::canonical<V, Backend>::type const&>(std::declval<typename boost::multiprecision::detail::canonical<V, Backend>::type>()))) 161 BOOST_NOEXCEPT_IF(noexcept(std::declval<Backend&>() = std::declval<const typename detail::canonical<V, Backend>::type&>()))
156 { 162 {
157 m_backend = canonical_value(v); 163 m_backend = canonical_value(v);
158 return *this; 164 return *this;
159 } 165 }
160 template <class V> 166 template <class V>
161 BOOST_MP_FORCEINLINE number<Backend, ExpressionTemplates>& assign(const V& v) 167 BOOST_MP_FORCEINLINE number<Backend, ExpressionTemplates>& assign(const V& v)
162 BOOST_NOEXCEPT_IF(noexcept(std::declval<Backend>() = static_cast<typename boost::multiprecision::detail::canonical<V, Backend>::type const&>(std::declval<typename boost::multiprecision::detail::canonical<V, Backend>::type>()))) 168 BOOST_NOEXCEPT_IF(noexcept(std::declval<Backend&>() = std::declval<const typename detail::canonical<V, Backend>::type&>()))
163 { 169 {
164 m_backend = canonical_value(v); 170 m_backend = canonical_value(v);
165 return *this; 171 return *this;
166 } 172 }
167 template <class Other, expression_template_option ET> 173 template <class Other, expression_template_option ET>
190 196
191 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES 197 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
192 BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(number&& r) 198 BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(number&& r)
193 BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval<Backend>()))) 199 BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval<Backend>())))
194 : m_backend(static_cast<Backend&&>(r.m_backend)){} 200 : m_backend(static_cast<Backend&&>(r.m_backend)){}
195 BOOST_MP_FORCEINLINE number& operator=(number&& r) BOOST_NOEXCEPT 201 BOOST_MP_FORCEINLINE number& operator=(number&& r) BOOST_NOEXCEPT_IF(noexcept(std::declval<Backend&>() = std::declval<Backend>()))
196 { 202 {
197 m_backend = static_cast<Backend&&>(r.m_backend); 203 m_backend = static_cast<Backend&&>(r.m_backend);
198 return *this; 204 return *this;
199 } 205 }
200 #endif 206 #endif
539 return *this; 545 return *this;
540 } 546 }
541 // 547 //
542 // swap: 548 // swap:
543 // 549 //
544 BOOST_MP_FORCEINLINE void swap(self_type& other) BOOST_NOEXCEPT 550 BOOST_MP_FORCEINLINE void swap(self_type& other) BOOST_NOEXCEPT_IF(noexcept(std::declval<Backend>().swap(std::declval<Backend&>())))
545 { 551 {
546 m_backend.swap(other.backend()); 552 m_backend.swap(other.backend());
547 } 553 }
548 // 554 //
549 // Zero and sign: 555 // Zero and sign:
576 { 582 {
577 using default_ops::eval_convert_to; 583 using default_ops::eval_convert_to;
578 eval_convert_to(result, m_backend); 584 eval_convert_to(result, m_backend);
579 } 585 }
580 template <class B2, expression_template_option ET> 586 template <class B2, expression_template_option ET>
581 void convert_to_imp(number<B2, ET>* result)const 587 typename enable_if_c<detail::is_explicitly_convertible<Backend, B2>::value>::type convert_to_imp(number<B2, ET>* result)const
582 { 588 {
583 result->assign(*this); 589 result->assign(*this);
584 } 590 }
585 void convert_to_imp(std::string* result)const 591 void convert_to_imp(std::string* result)const
586 { 592 {
596 } 602 }
597 // 603 //
598 // Use in boolean context, and explicit conversion operators: 604 // Use in boolean context, and explicit conversion operators:
599 // 605 //
600 #ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS 606 #ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
601 # if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 7) 607 # if (defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 7)) || (defined(BOOST_INTEL) && (BOOST_INTEL <= 1500))
602 // 608 //
603 // Horrible workaround for gcc-4.6.x which always prefers the template 609 // Horrible workaround for gcc-4.6.x which always prefers the template
604 // operator bool() rather than the non-template operator when converting to 610 // operator bool() rather than the non-template operator when converting to
605 // an arithmetic type: 611 // an arithmetic type:
606 // 612 //
1380 typedef typename Exp::left_type left_type; 1386 typedef typename Exp::left_type left_type;
1381 typedef typename Exp::right_type right_type; 1387 typedef typename Exp::right_type right_type;
1382 do_multiplies(e.left(), typename left_type::tag_type()); 1388 do_multiplies(e.left(), typename left_type::tag_type());
1383 do_multiplies(e.right(), typename right_type::tag_type()); 1389 do_multiplies(e.right(), typename right_type::tag_type());
1384 } 1390 }
1385 1391 //
1386 template <class Exp> 1392 // This rearrangement is disabled for integer types, the test on sizeof(Exp) is simply to make
1387 void do_multiplies(const Exp& e, const detail::divides&) 1393 // the disable_if dependent on the template argument (the size of 1 can never occur in practice).
1394 //
1395 template <class Exp>
1396 typename boost::disable_if_c<boost::multiprecision::number_category<self_type>::value == boost::multiprecision::number_kind_integer || sizeof(Exp) == 1>::type
1397 do_multiplies(const Exp& e, const detail::divides&)
1388 { 1398 {
1389 typedef typename Exp::left_type left_type; 1399 typedef typename Exp::left_type left_type;
1390 typedef typename Exp::right_type right_type; 1400 typedef typename Exp::right_type right_type;
1391 do_multiplies(e.left(), typename left_type::tag_type()); 1401 do_multiplies(e.left(), typename left_type::tag_type());
1392 do_divide(e.right(), typename right_type::tag_type()); 1402 do_divide(e.right(), typename right_type::tag_type());
1397 { 1407 {
1398 using default_ops::eval_multiply; 1408 using default_ops::eval_multiply;
1399 eval_multiply(m_backend, canonical_value(e.left().value())); 1409 eval_multiply(m_backend, canonical_value(e.left().value()));
1400 eval_multiply(m_backend, canonical_value(e.right().value())); 1410 eval_multiply(m_backend, canonical_value(e.right().value()));
1401 } 1411 }
1402 template <class Exp> 1412 //
1403 void do_multiplies(const Exp& e, const detail::divide_immediates&) 1413 // This rearrangement is disabled for integer types, the test on sizeof(Exp) is simply to make
1414 // the disable_if dependent on the template argument (the size of 1 can never occur in practice).
1415 //
1416 template <class Exp>
1417 typename boost::disable_if_c<boost::multiprecision::number_category<self_type>::value == boost::multiprecision::number_kind_integer || sizeof(Exp) == 1>::type
1418 do_multiplies(const Exp& e, const detail::divide_immediates&)
1404 { 1419 {
1405 using default_ops::eval_multiply; 1420 using default_ops::eval_multiply;
1406 using default_ops::eval_divide; 1421 using default_ops::eval_divide;
1407 eval_multiply(m_backend, canonical_value(e.left().value())); 1422 eval_multiply(m_backend, canonical_value(e.left().value()));
1408 eval_divide(m_backend, canonical_value(e.right().value())); 1423 eval_divide(m_backend, canonical_value(e.right().value()));
1427 { 1442 {
1428 typedef typename Exp::left_type left_type; 1443 typedef typename Exp::left_type left_type;
1429 do_divide(e.left(), typename left_type::tag_type()); 1444 do_divide(e.left(), typename left_type::tag_type());
1430 m_backend.negate(); 1445 m_backend.negate();
1431 } 1446 }
1432 1447 //
1433 template <class Exp> 1448 // This rearrangement is disabled for integer types, the test on sizeof(Exp) is simply to make
1434 void do_divide(const Exp& e, const detail::multiplies&) 1449 // the disable_if dependent on the template argument (the size of 1 can never occur in practice).
1450 //
1451 template <class Exp>
1452 typename boost::disable_if_c<boost::multiprecision::number_category<self_type>::value == boost::multiprecision::number_kind_integer || sizeof(Exp) == 1>::type
1453 do_divide(const Exp& e, const detail::multiplies&)
1435 { 1454 {
1436 typedef typename Exp::left_type left_type; 1455 typedef typename Exp::left_type left_type;
1437 typedef typename Exp::right_type right_type; 1456 typedef typename Exp::right_type right_type;
1438 do_divide(e.left(), typename left_type::tag_type()); 1457 do_divide(e.left(), typename left_type::tag_type());
1439 do_divide(e.right(), typename right_type::tag_type()); 1458 do_divide(e.right(), typename right_type::tag_type());
1440 } 1459 }
1441 1460 //
1442 template <class Exp> 1461 // This rearrangement is disabled for integer types, the test on sizeof(Exp) is simply to make
1443 void do_divide(const Exp& e, const detail::divides&) 1462 // the disable_if dependent on the template argument (the size of 1 can never occur in practice).
1463 //
1464 template <class Exp>
1465 typename boost::disable_if_c<boost::multiprecision::number_category<self_type>::value == boost::multiprecision::number_kind_integer || sizeof(Exp) == 1>::type
1466 do_divide(const Exp& e, const detail::divides&)
1444 { 1467 {
1445 typedef typename Exp::left_type left_type; 1468 typedef typename Exp::left_type left_type;
1446 typedef typename Exp::right_type right_type; 1469 typedef typename Exp::right_type right_type;
1447 do_divide(e.left(), typename left_type::tag_type()); 1470 do_divide(e.left(), typename left_type::tag_type());
1448 do_multiplies(e.right(), typename right_type::tag_type()); 1471 do_multiplies(e.right(), typename right_type::tag_type());
1449 } 1472 }
1450 1473 //
1451 template <class Exp> 1474 // This rearrangement is disabled for integer types, the test on sizeof(Exp) is simply to make
1452 void do_divides(const Exp& e, const detail::multiply_immediates&) 1475 // the disable_if dependent on the template argument (the size of 1 can never occur in practice).
1476 //
1477 template <class Exp>
1478 typename boost::disable_if_c<boost::multiprecision::number_category<self_type>::value == boost::multiprecision::number_kind_integer || sizeof(Exp) == 1>::type
1479 do_divides(const Exp& e, const detail::multiply_immediates&)
1453 { 1480 {
1454 using default_ops::eval_divide; 1481 using default_ops::eval_divide;
1455 eval_divide(m_backend, canonical_value(e.left().value())); 1482 eval_divide(m_backend, canonical_value(e.left().value()));
1456 eval_divide(m_backend, canonical_value(e.right().value())); 1483 eval_divide(m_backend, canonical_value(e.right().value()));
1457 } 1484 }
1458 template <class Exp> 1485 //
1459 void do_divides(const Exp& e, const detail::divide_immediates&) 1486 // This rearrangement is disabled for integer types, the test on sizeof(Exp) is simply to make
1487 // the disable_if dependent on the template argument (the size of 1 can never occur in practice).
1488 //
1489 template <class Exp>
1490 typename boost::disable_if_c<boost::multiprecision::number_category<self_type>::value == boost::multiprecision::number_kind_integer || sizeof(Exp) == 1>::type
1491 do_divides(const Exp& e, const detail::divide_immediates&)
1460 { 1492 {
1461 using default_ops::eval_multiply; 1493 using default_ops::eval_multiply;
1462 using default_ops::eval_divide; 1494 using default_ops::eval_divide;
1463 eval_divide(m_backend, canonical_value(e.left().value())); 1495 eval_divide(m_backend, canonical_value(e.left().value()));
1464 mutiply(m_backend, canonical_value(e.right().value())); 1496 mutiply(m_backend, canonical_value(e.right().value()));
1658 { 1690 {
1659 char fill = os.fill(); 1691 char fill = os.fill();
1660 if((os.flags() & std::ios_base::left) == std::ios_base::left) 1692 if((os.flags() & std::ios_base::left) == std::ios_base::left)
1661 s.append(static_cast<std::string::size_type>(ss - s.size()), fill); 1693 s.append(static_cast<std::string::size_type>(ss - s.size()), fill);
1662 else 1694 else
1663 s.insert(0, static_cast<std::string::size_type>(ss - s.size()), fill); 1695 s.insert(static_cast<std::string::size_type>(0), static_cast<std::string::size_type>(ss - s.size()), fill);
1664 } 1696 }
1665 return os << s; 1697 return os << s;
1666 } 1698 }
1667 1699
1668 namespace detail{ 1700 namespace detail{
1691 r.assign(s); 1723 r.assign(s);
1692 return is; 1724 return is;
1693 } 1725 }
1694 1726
1695 template <class Backend, expression_template_option ExpressionTemplates> 1727 template <class Backend, expression_template_option ExpressionTemplates>
1696 BOOST_MP_FORCEINLINE void swap(number<Backend, ExpressionTemplates>& a, number<Backend, ExpressionTemplates>& b) 1728 BOOST_MP_FORCEINLINE void swap(number<Backend, ExpressionTemplates>& a, number<Backend, ExpressionTemplates>& b)
1729 BOOST_NOEXCEPT_IF(noexcept(std::declval<number<Backend, ExpressionTemplates>&>() = std::declval<number<Backend, ExpressionTemplates>&>()))
1697 { 1730 {
1698 a.swap(b); 1731 a.swap(b);
1699 } 1732 }
1700 1733
1701 } // namespace multiprecision 1734 } // namespace multiprecision
1719 have_hex = true; 1752 have_hex = true;
1720 s1.append(1, c); 1753 s1.append(1, c);
1721 is.get(); 1754 is.get();
1722 } 1755 }
1723 if(hex_format && ((s1[0] != '0') || (s1[1] != 'x'))) 1756 if(hex_format && ((s1[0] != '0') || (s1[1] != 'x')))
1724 s1.insert(0, "0x"); 1757 s1.insert(static_cast<std::string::size_type>(0), "0x");
1725 if(oct_format && (s1[0] != '0')) 1758 if(oct_format && (s1[0] != '0'))
1726 s1.insert(0, "0"); 1759 s1.insert(static_cast<std::string::size_type>(0), "0");
1727 v1.assign(s1); 1760 v1.assign(s1);
1728 s1.erase(); 1761 s1.erase();
1729 if(c == '/') 1762 if(c == '/')
1730 { 1763 {
1731 is.get(); 1764 is.get();
1735 have_hex = true; 1768 have_hex = true;
1736 s1.append(1, c); 1769 s1.append(1, c);
1737 is.get(); 1770 is.get();
1738 } 1771 }
1739 if(hex_format && ((s1[0] != '0') || (s1[1] != 'x'))) 1772 if(hex_format && ((s1[0] != '0') || (s1[1] != 'x')))
1740 s1.insert(0, "0x"); 1773 s1.insert(static_cast<std::string::size_type>(0), "0x");
1741 if(oct_format && (s1[0] != '0')) 1774 if(oct_format && (s1[0] != '0'))
1742 s1.insert(0, "0"); 1775 s1.insert(static_cast<std::string::size_type>(0), "0");
1743 v2.assign(s1); 1776 v2.assign(s1);
1744 } 1777 }
1745 else 1778 else
1746 v2 = 1; 1779 v2 = 1;
1747 r.assign(v1, v2); 1780 r.assign(v1, v2);
1782 inline multiprecision::number<T, ExpressionTemplates> denominator(const rational<multiprecision::number<T, ExpressionTemplates> >& a) 1815 inline multiprecision::number<T, ExpressionTemplates> denominator(const rational<multiprecision::number<T, ExpressionTemplates> >& a)
1783 { 1816 {
1784 return a.denominator(); 1817 return a.denominator();
1785 } 1818 }
1786 1819
1820 namespace multiprecision
1821 {
1822
1823 template <class I>
1824 struct component_type<boost::rational<I> >
1825 {
1826 typedef I type;
1827 };
1828
1829 }
1830
1787 #ifdef BOOST_MSVC 1831 #ifdef BOOST_MSVC
1788 #pragma warning(pop) 1832 #pragma warning(pop)
1789 #endif 1833 #endif
1790 1834
1791 } // namespaces 1835 } // namespaces