libstdc++
constructor_destructor_fn_imps.hpp
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // Copyright (C) 2005-2013 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the terms
00007 // of the GNU General Public License as published by the Free Software
00008 // Foundation; either version 3, or (at your option) any later
00009 // version.
00010 
00011 // This library is distributed in the hope that it will be useful, but
00012 // WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // General Public License for more details.
00015 
00016 // Under Section 7 of GPL version 3, you are granted additional
00017 // permissions described in the GCC Runtime Library Exception, version
00018 // 3.1, as published by the Free Software Foundation.
00019 
00020 // You should have received a copy of the GNU General Public License and
00021 // a copy of the GCC Runtime Library Exception along with this program;
00022 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00023 // <http://www.gnu.org/licenses/>.
00024 
00025 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
00026 
00027 // Permission to use, copy, modify, sell, and distribute this software
00028 // is hereby granted without fee, provided that the above copyright
00029 // notice appears in all copies, and that both that copyright notice
00030 // and this permission notice appear in supporting documentation. None
00031 // of the above authors, nor IBM Haifa Research Laboratories, make any
00032 // representation about the suitability of this software for any
00033 // purpose. It is provided "as is" without express or implied
00034 // warranty.
00035 
00036 /**
00037  * @file list_update_map_/constructor_destructor_fn_imps.hpp
00038  */
00039 
00040 PB_DS_CLASS_T_DEC
00041 typename PB_DS_CLASS_C_DEC::entry_allocator
00042 PB_DS_CLASS_C_DEC::s_entry_allocator;
00043 
00044 PB_DS_CLASS_T_DEC
00045 Eq_Fn PB_DS_CLASS_C_DEC::s_eq_fn;
00046 
00047 PB_DS_CLASS_T_DEC
00048 null_type PB_DS_CLASS_C_DEC::s_null_type;
00049 
00050 PB_DS_CLASS_T_DEC
00051 Update_Policy PB_DS_CLASS_C_DEC::s_update_policy;
00052 
00053 PB_DS_CLASS_T_DEC
00054 type_to_type<
00055   typename PB_DS_CLASS_C_DEC::update_metadata> PB_DS_CLASS_C_DEC::s_metadata_type_indicator;
00056 
00057 PB_DS_CLASS_T_DEC
00058 template<typename It>
00059 void
00060 PB_DS_CLASS_C_DEC::
00061 copy_from_range(It first_it, It last_it)
00062 {
00063   while (first_it != last_it)
00064     insert(*(first_it++));
00065 }
00066 
00067 PB_DS_CLASS_T_DEC
00068 PB_DS_CLASS_C_DEC::
00069 PB_DS_LU_NAME() : m_p_l(0)
00070 { PB_DS_ASSERT_VALID((*this)) }
00071 
00072 PB_DS_CLASS_T_DEC
00073 template<typename It>
00074 PB_DS_CLASS_C_DEC::
00075 PB_DS_LU_NAME(It first_it, It last_it) : m_p_l(0)
00076 {
00077   copy_from_range(first_it, last_it);
00078   PB_DS_ASSERT_VALID((*this));
00079 }
00080 
00081 PB_DS_CLASS_T_DEC
00082 PB_DS_CLASS_C_DEC::
00083 PB_DS_LU_NAME(const PB_DS_CLASS_C_DEC& other) :
00084 m_p_l(0)
00085 {
00086   __try
00087     {
00088       for (const_iterator it = other.begin(); it != other.end(); ++it)
00089     {
00090       entry_pointer p_l = allocate_new_entry(*it,
00091                       traits_base::m_no_throw_copies_indicator);
00092 
00093       p_l->m_p_next = m_p_l;
00094       m_p_l = p_l;
00095     }
00096     }
00097   __catch(...)
00098     {
00099       deallocate_all();
00100       __throw_exception_again;
00101     }
00102   PB_DS_ASSERT_VALID((*this))
00103 }
00104 
00105 PB_DS_CLASS_T_DEC
00106 void
00107 PB_DS_CLASS_C_DEC::
00108 swap(PB_DS_CLASS_C_DEC& other)
00109 {
00110   PB_DS_ASSERT_VALID((*this))
00111   PB_DS_ASSERT_VALID(other)
00112   _GLIBCXX_DEBUG_ONLY(debug_base::swap(other);)
00113   std::swap(m_p_l, other.m_p_l);
00114   PB_DS_ASSERT_VALID((*this))
00115   PB_DS_ASSERT_VALID(other)
00116 }
00117 
00118 PB_DS_CLASS_T_DEC
00119 void
00120 PB_DS_CLASS_C_DEC::
00121 deallocate_all()
00122 {
00123   entry_pointer p_l = m_p_l;
00124   while (p_l != 0)
00125     {
00126       entry_pointer p_next_l = p_l->m_p_next;
00127       actual_erase_entry(p_l);
00128       p_l = p_next_l;
00129     }
00130   m_p_l = 0;
00131 }
00132 
00133 PB_DS_CLASS_T_DEC
00134 PB_DS_CLASS_C_DEC::
00135 ~PB_DS_LU_NAME()
00136 { deallocate_all(); }