Ticket #9939: dynamic-bitset-no-exceptions-patch.txt

File dynamic-bitset-no-exceptions-patch.txt, 3.7 KB (added by Boleslaw Ciesielski <bolek@…>, 9 years ago)

patch to add no exceptions support

Line 
1diff --git a/include/boost/dynamic_bitset/dynamic_bitset.hpp b/include/boost/dynamic_bitset/dynamic_bitset.hpp
2index a722324..1554786 100644
3--- a/include/boost/dynamic_bitset/dynamic_bitset.hpp
4+++ b/include/boost/dynamic_bitset/dynamic_bitset.hpp
5@@ -42,6 +42,7 @@
6 #include "boost/pending/lowest_bit.hpp"
7 #include "boost/static_assert.hpp"
8 #include "boost/utility/addressof.hpp"
9+#include "boost/detail/no_exceptions_support.hpp"
10
11
12 namespace boost {
13@@ -1179,7 +1180,7 @@ to_ulong() const
14 // Check for overflows. This may be a performance burden on very
15 // large bitsets but is required by the specification, sorry
16 if (find_next(ulong_width - 1) != npos)
17- throw std::overflow_error("boost::dynamic_bitset::to_ulong overflow");
18+ BOOST_THROW_EXCEPTION(std::overflow_error("boost::dynamic_bitset::to_ulong overflow"));
19
20
21 // Ok, from now on we can be sure there's no "on" bit
22@@ -1500,7 +1501,7 @@ operator<<(std::basic_ostream<Ch, Tr>& os,
23 const Ch zero = BOOST_DYNAMIC_BITSET_WIDEN_CHAR(fac, '0');
24 const Ch one = BOOST_DYNAMIC_BITSET_WIDEN_CHAR(fac, '1');
25
26- try {
27+ BOOST_TRY {
28
29 typedef typename dynamic_bitset<Block, Alloc>::size_type bitset_size_type;
30 typedef basic_streambuf<Ch, Tr> buffer_type;
31@@ -1547,13 +1548,14 @@ operator<<(std::basic_ostream<Ch, Tr>& os,
32
33 os.width(0);
34
35- } catch (...) { // see std 27.6.1.1/4
36+ } BOOST_CATCH (...) { // see std 27.6.1.1/4
37 bool rethrow = false;
38- try { os.setstate(ios_base::failbit); } catch (...) { rethrow = true; }
39+ BOOST_TRY { os.setstate(ios_base::failbit); } BOOST_CATCH (...) { rethrow = true; } BOOST_CATCH_END
40
41 if (rethrow)
42- throw;
43+ BOOST_RETHROW;
44 }
45+ BOOST_CATCH_END
46 }
47
48 if(err != ok)
49@@ -1612,13 +1614,14 @@ operator>>(std::istream& is, dynamic_bitset<Block, Alloc>& b)
50 break; // non digit character
51
52 else {
53- try {
54+ BOOST_TRY {
55 appender.do_append(char(c) == '1');
56 }
57- catch(...) {
58+ BOOST_CATCH(...) {
59 is.setstate(std::ios::failbit); // assume this can't throw
60- throw;
61+ BOOST_RETHROW;
62 }
63+ BOOST_CATCH_END
64 }
65
66 } // for
67@@ -1659,7 +1662,7 @@ operator>>(std::basic_istream<Ch, Tr>& is, dynamic_bitset<Block, Alloc>& b)
68 const Ch one = BOOST_DYNAMIC_BITSET_WIDEN_CHAR(fac, '1');
69
70 b.clear();
71- try {
72+ BOOST_TRY {
73 typename bitset_type::bit_appender appender(b);
74 basic_streambuf <Ch, Tr> * buf = is.rdbuf();
75 typename Tr::int_type c = buf->sgetc();
76@@ -1682,7 +1685,7 @@ operator>>(std::basic_istream<Ch, Tr>& is, dynamic_bitset<Block, Alloc>& b)
77
78 } // for
79 }
80- catch (...) {
81+ BOOST_CATCH (...) {
82 // catches from stream buf, or from vector:
83 //
84 // bits_stored bits have been extracted and stored, and
85@@ -1690,13 +1693,15 @@ operator>>(std::basic_istream<Ch, Tr>& is, dynamic_bitset<Block, Alloc>& b)
86 // append to the underlying vector (out of memory)
87
88 bool rethrow = false; // see std 27.6.1.1/4
89- try { is.setstate(ios_base::badbit); }
90- catch(...) { rethrow = true; }
91+ BOOST_TRY { is.setstate(ios_base::badbit); }
92+ BOOST_CATCH(...) { rethrow = true; }
93+ BOOST_CATCH_END
94
95 if (rethrow)
96- throw;
97+ BOOST_RETHROW;
98
99 }
100+ BOOST_CATCH_END
101 }
102
103 is.width(0);