Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:40:52

0001 //////////////////////////////////////////////////////////////////////////////
0002 //
0003 // (C) Copyright Ion Gaztanaga 2015-2016.
0004 // Distributed under the Boost Software License, Version 1.0.
0005 // (See accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt)
0007 //
0008 // See http://www.boost.org/libs/move for documentation.
0009 //
0010 //////////////////////////////////////////////////////////////////////////////
0011 
0012 //! \file
0013 
0014 #ifndef BOOST_MOVE_DETAIL_DESTRUCT_N_HPP
0015 #define BOOST_MOVE_DETAIL_DESTRUCT_N_HPP
0016 
0017 #ifndef BOOST_CONFIG_HPP
0018 #  include <boost/config.hpp>
0019 #endif
0020 #
0021 #if defined(BOOST_HAS_PRAGMA_ONCE)
0022 #  pragma once
0023 #endif
0024 
0025 #include <cstddef>
0026 
0027 namespace boost {
0028 namespace movelib{
0029 
0030 template<class T, class RandItUninit>
0031 class destruct_n
0032 {
0033    public:
0034    explicit destruct_n(RandItUninit raw)
0035       : m_ptr(raw), m_size()
0036    {}
0037 
0038    void incr()
0039    {
0040       ++m_size;
0041    }
0042 
0043    void incr(std::size_t n)
0044    {
0045       m_size += n;
0046    }
0047 
0048    void release()
0049    {
0050       m_size = 0u;
0051    }
0052 
0053    ~destruct_n()
0054    {
0055       while(m_size--){
0056          m_ptr[m_size].~T();
0057       }
0058    }
0059    private:
0060    RandItUninit m_ptr;
0061    std::size_t m_size;
0062 };
0063 
0064 }} //namespace boost {  namespace movelib{
0065 
0066 #endif //#ifndef BOOST_MOVE_DETAIL_DESTRUCT_N_HPP