Ticket #10974: dynamic_bitset.patch
File dynamic_bitset.patch, 6.9 KB (added by , 8 years ago) |
---|
-
boost/dynamic_bitset/dynamic_bitset.hpp
old new 1427 1427 // ships with gcc 2.95 has an exceptions() member function but 1428 1428 // nothing is actually implemented; not even the class ios::failure. 1429 1429 1430 using namespace std; 1431 1432 const ios::iostate ok = ios::goodbit; 1433 ios::iostate err = ok; 1430 const std::ios::iostate ok = std::ios::goodbit; 1431 std::ios::iostate err = ok; 1434 1432 1435 1433 if (os.opfx()) { 1436 1434 … … 1443 1441 || (bitsetsize_type) os.width() <= sz? 0 : os.width() - sz; 1444 1442 1445 1443 const char fill_char = os.fill(); 1446 const ios::fmtflags adjustfield = os.flags() &ios::adjustfield;1444 const std::ios::fmtflags adjustfield = os.flags() & std::ios::adjustfield; 1447 1445 1448 1446 // if needed fill at left; pad is decresed along the way 1449 if ( adjustfield !=ios::left) {1447 if (std::ios::adjustfield != std::ios::left) { 1450 1448 for (; 0 < npad; --npad) 1451 1449 if (fill_char != buf->sputc(fill_char)) { 1452 err |= ios::failbit;1450 err |= std::ios::failbit; 1453 1451 break; 1454 1452 } 1455 1453 } … … 1459 1457 for (bitsetsize_type i = b.size(); 0 < i; --i) { 1460 1458 const char dig = b.test(i-1)? '1' : '0'; 1461 1459 if (EOF == buf->sputc(dig)) { 1462 err |= ios::failbit;1460 err |= std::ios::failbit; 1463 1461 break; 1464 1462 } 1465 1463 } … … 1469 1467 // if needed fill at right 1470 1468 for (; 0 < npad; --npad) { 1471 1469 if (fill_char != buf->sputc(fill_char)) { 1472 err |= ios::failbit;1470 err |= std::ios::failbit; 1473 1471 break; 1474 1472 } 1475 1473 } … … 1493 1491 const dynamic_bitset<Block, Alloc>& b) 1494 1492 { 1495 1493 1496 using namespace std; 1497 1498 const ios_base::iostate ok = ios_base::goodbit; 1499 ios_base::iostate err = ok; 1494 const std::ios_base::iostate ok = std::ios_base::goodbit; 1495 std::ios_base::iostate err = ok; 1500 1496 1501 typename basic_ostream<Ch, Tr>::sentry cerberos(os);1497 typename std::basic_ostream<Ch, Tr>::sentry cerberos(os); 1502 1498 if (cerberos) { 1503 1499 1504 1500 BOOST_DYNAMIC_BITSET_CTYPE_FACET(Ch, fac, os.getloc()); … … 1508 1504 BOOST_TRY { 1509 1505 1510 1506 typedef typename dynamic_bitset<Block, Alloc>::size_type bitset_size_type; 1511 typedef basic_streambuf<Ch, Tr> buffer_type;1507 typedef std::basic_streambuf<Ch, Tr> buffer_type; 1512 1508 1513 1509 buffer_type * buf = os.rdbuf(); 1514 1510 // careful: os.width() is signed (and can be < 0) 1515 1511 const bitset_size_type width = (os.width() <= 0) ? 0 : static_cast<bitset_size_type>(os.width()); 1516 st reamsize npad = (width <= b.size()) ? 0 : width - b.size();1512 std::streamsize npad = (width <= b.size()) ? 0 : width - b.size(); 1517 1513 1518 1514 const Ch fill_char = os.fill(); 1519 const ios_base::fmtflags adjustfield = os.flags() &ios_base::adjustfield;1515 const std::ios_base::fmtflags adjustfield = os.flags() & std::ios_base::adjustfield; 1520 1516 1521 1517 // if needed fill at left; pad is decreased along the way 1522 if (adjustfield != ios_base::left) {1518 if (adjustfield != std::ios_base::left) { 1523 1519 for (; 0 < npad; --npad) 1524 1520 if (Tr::eq_int_type(Tr::eof(), buf->sputc(fill_char))) { 1525 err |= ios_base::failbit;1521 err |= std::ios_base::failbit; 1526 1522 break; 1527 1523 } 1528 1524 } … … 1533 1529 typename buffer_type::int_type 1534 1530 ret = buf->sputc(b.test(i-1)? one : zero); 1535 1531 if (Tr::eq_int_type(Tr::eof(), ret)) { 1536 err |= ios_base::failbit;1532 err |= std::ios_base::failbit; 1537 1533 break; 1538 1534 } 1539 1535 } … … 1543 1539 // if needed fill at right 1544 1540 for (; 0 < npad; --npad) { 1545 1541 if (Tr::eq_int_type(Tr::eof(), buf->sputc(fill_char))) { 1546 err |= ios_base::failbit;1542 err |= std::ios_base::failbit; 1547 1543 break; 1548 1544 } 1549 1545 } … … 1554 1550 1555 1551 } BOOST_CATCH (...) { // see std 27.6.1.1/4 1556 1552 bool rethrow = false; 1557 BOOST_TRY { os.setstate( ios_base::failbit); } BOOST_CATCH (...) { rethrow = true; } BOOST_CATCH_END1553 BOOST_TRY { os.setstate(std::ios_base::failbit); } BOOST_CATCH (...) { rethrow = true; } BOOST_CATCH_END 1558 1554 1559 1555 if (rethrow) 1560 1556 BOOST_RETHROW; … … 1647 1643 operator>>(std::basic_istream<Ch, Tr>& is, dynamic_bitset<Block, Alloc>& b) 1648 1644 { 1649 1645 1650 using namespace std;1651 1652 1646 typedef dynamic_bitset<Block, Alloc> bitset_type; 1653 1647 typedef typename bitset_type::size_type size_type; 1654 1648 1655 const st reamsize w = is.width();1649 const std::streamsize w = is.width(); 1656 1650 const size_type limit = 0 < w && static_cast<size_type>(w) < b.max_size()? 1657 1651 static_cast<size_type>(w) : b.max_size(); 1658 1652 1659 ios_base::iostate err =ios_base::goodbit;1660 typename basic_istream<Ch, Tr>::sentry cerberos(is); // skips whitespaces1653 std::ios_base::iostate err = std::ios_base::goodbit; 1654 typename std::basic_istream<Ch, Tr>::sentry cerberos(is); // skips whitespaces 1661 1655 if(cerberos) { 1662 1656 1663 1657 // in accordance with prop. resol. of lib DR 303 [last checked 4 Feb 2004] … … 1668 1662 b.clear(); 1669 1663 BOOST_TRY { 1670 1664 typename bitset_type::bit_appender appender(b); 1671 basic_streambuf <Ch, Tr> * buf = is.rdbuf();1665 std::basic_streambuf <Ch, Tr> * buf = is.rdbuf(); 1672 1666 typename Tr::int_type c = buf->sgetc(); 1673 1667 for( ; appender.get_count() < limit; c = buf->snextc() ) { 1674 1668 1675 1669 if (Tr::eq_int_type(Tr::eof(), c)) { 1676 err |= ios_base::eofbit;1670 err |= std::ios_base::eofbit; 1677 1671 break; 1678 1672 } 1679 1673 else { … … 1697 1691 // append to the underlying vector (out of memory) 1698 1692 1699 1693 bool rethrow = false; // see std 27.6.1.1/4 1700 BOOST_TRY { is.setstate( ios_base::badbit); }1694 BOOST_TRY { is.setstate(std::ios_base::badbit); } 1701 1695 BOOST_CATCH(...) { rethrow = true; } 1702 1696 BOOST_CATCH_END 1703 1697 … … 1710 1704 1711 1705 is.width(0); 1712 1706 if (b.size() == 0 /*|| !cerberos*/) 1713 err |= ios_base::failbit;1714 if (err != ios_base::goodbit)1707 err |= std::ios_base::failbit; 1708 if (err != std::ios_base::goodbit) 1715 1709 is.setstate (err); // may throw 1716 1710 1717 1711 return is;