| 1452 | template <class ...Args> |
| 1453 | void emplace_back_impl(BOOST_FWD_REF(Args) ...args) { |
| 1454 | if (full()) { |
| 1455 | if (empty()) |
| 1456 | return; |
| 1457 | replace(m_last, value_type(::boost::forward<Args>(args)...)); |
| 1458 | increment(m_last); |
| 1459 | m_first = m_last; |
| 1460 | } else { |
| 1461 | boost::container::allocator_traits<Alloc>::construct(m_alloc, cb_details::to_address(m_last), ::boost::forward<Args>(args)...); |
| 1462 | increment(m_last); |
| 1463 | ++m_size; |
| 1464 | } |
| 1465 | } |
| 1466 | |
| 1467 | template <class ...Args> |
| 1468 | void emplace_front_impl(BOOST_FWD_REF(Args) ...args) { |
| 1469 | BOOST_TRY { |
| 1470 | if (full()) { |
| 1471 | if (empty()) |
| 1472 | return; |
| 1473 | decrement(m_first); |
| 1474 | replace(m_first, value_type(::boost::forward<Args>(args)...)); |
| 1475 | m_last = m_first; |
| 1476 | } else { |
| 1477 | decrement(m_first); |
| 1478 | boost::container::allocator_traits<Alloc>::construct(m_alloc, cb_details::to_address(m_first), ::boost::forward<Args>(args)...); |
| 1479 | ++m_size; |
| 1480 | } |
| 1481 | } BOOST_CATCH(...) { |
| 1482 | increment(m_first); |
| 1483 | BOOST_RETHROW |
| 1484 | } |
| 1485 | BOOST_CATCH_END |
| 1486 | } |
| 1487 | |
| 1617 | //! Construct a new element at the end of the <code>circular_buffer</code>. |
| 1618 | /*! |
| 1619 | \post if <code>capacity() > 0</code> then <code>back() == item</code><br> |
| 1620 | If the <code>circular_buffer</code> is full, the first element will be removed. If the capacity is |
| 1621 | <code>0</code>, nothing will be inserted. |
| 1622 | \param item The element to be inserted. |
| 1623 | \throws Whatever <code>T::T(Args...)</code> throws. |
| 1624 | Whatever <code>T::operator = (T&&)</code> throws. |
| 1625 | \par Exception Safety |
| 1626 | Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything. |
| 1627 | \par Iterator Invalidation |
| 1628 | Does not invalidate any iterators with the exception of iterators pointing to the overwritten element. |
| 1629 | \par Complexity |
| 1630 | Constant (in the size of the <code>circular_buffer</code>). |
| 1631 | \sa <code>\link push_back() push_back(const_reference)\endlink</code>, |
| 1632 | <code>pop_back()</code>, <code>emplace_front()</code> |
| 1633 | */ |
| 1634 | template <class ...Args> |
| 1635 | void emplace_back(BOOST_FWD_REF(Args) ...args) { |
| 1636 | emplace_back_impl(::boost::forward<Args>(args)...); |
| 1637 | } |
| 1638 | |
| 1639 | //! Construct a new element at the beginning of the <code>circular_buffer</code>. |
| 1640 | /*! |
| 1641 | \post if <code>capacity() > 0</code> then <code>back() == item</code><br> |
| 1642 | If the <code>circular_buffer</code> is full, the last element will be removed. If the capacity is |
| 1643 | <code>0</code>, nothing will be inserted. |
| 1644 | \param item The element to be inserted. |
| 1645 | \throws Whatever <code>T::T(Args...)</code> throws. |
| 1646 | Whatever <code>T::operator = (T&&)</code> throws. |
| 1647 | \par Exception Safety |
| 1648 | Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything. |
| 1649 | \par Iterator Invalidation |
| 1650 | Does not invalidate any iterators with the exception of iterators pointing to the overwritten element. |
| 1651 | \par Complexity |
| 1652 | Constant (in the size of the <code>circular_buffer</code>). |
| 1653 | \sa <code>\link push_front() push_front(const_reference)\endlink</code>, |
| 1654 | <code>pop_front()</code>, <code>emplace_back()</code> |
| 1655 | */ |
| 1656 | template <class ...Args> |
| 1657 | void emplace_front(BOOST_FWD_REF(Args) ...args) { |
| 1658 | emplace_front_impl(::boost::forward<Args>(args)...); |
| 1659 | } |
| 1660 | |