VirtualBox

Changeset 97946 in vbox for trunk/include/iprt/nocrt


Ignore:
Timestamp:
Jan 3, 2023 8:53:28 AM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
155037
Message:

IPRT: include/iprt/nocrt/vector: Compilation fix for data(), added a separate clear() function -- Thanks to Martin Fleisz!

Additionally, fixed a compilation issue for reference (operator *) item access on Linux.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/nocrt/vector

    r97821 r97946  
    44
    55/*
    6  * Copyright (C) 2022 Oracle and/or its affiliates.
     6 * Copyright (C) 2023 Oracle and/or its affiliates.
    77 *
    88 * This file is part of VirtualBox base platform packages, as
     
    120120        /** @name Item access
    121121         * @{ */
    122         typename reference operator*() const RT_NOEXCEPT
     122        reference operator*() const RT_NOEXCEPT
    123123        {
    124124            return *m_pItem;
     
    229229        ~vector()
    230230        {
    231             size_type i = m_cItems;
    232             while (i-- > 0)
    233             {
    234                 m_Allocator.destroy(&m_paItems[i]);
    235                 m_cItems = i;
    236             }
    237             m_Allocator.deallocate(m_paItems, m_cAllocated);
    238             m_paItems    = NULL;
    239             m_cAllocated = 0;
    240         }
    241 
     231            clear();
     232        }
    242233
    243234        /** @name Iterators
     
    310301        pointer data() RT_NOEXCEPT
    311302        {
    312             return m_paItem;
     303            return m_paItems;
    313304        }
    314305
    315306        const_pointer data() const RT_NOEXCEPT
    316307        {
    317             return m_paItem;
     308            return m_paItems;
    318309        }
    319310
     
    386377                m_cItems -= 1;
    387378        }
    388         /** @} */
    389 
     379
     380        void clear() RT_NOEXCEPT
     381        {
     382            size_type i = m_cItems;
     383            while (i-- > 0)
     384            {
     385                m_Allocator.destroy(&m_paItems[i]);
     386                m_cItems = i;
     387            }
     388            m_Allocator.deallocate(m_paItems, m_cAllocated);
     389            m_paItems = NULL;
     390            m_cAllocated = 0;
     391        }
     392        /** @} */
    390393    };
    391394
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette