LCOV - lcov.info - /usr/include/c++/4.3/bits/stl_construct.h

LTP GCOV extension - code coverage report
Current view: | directory - usr/include/c++/4.3/bits - stl_construct.h
Test: | lcov.info
Date: | 2008-08-14 |  | Instrumented lines: | 12
Code covered: | 100.0 % |  | Executed lines: | 12

           1                 : // nonstandard construct and destroy functions -*- C++ -*-
           2                 :
           3                 : // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
           4                 : // Free Software Foundation, Inc.
           5                 : //
           6                 : // This file is part of the GNU ISO C++ Library.  This library is free
           7                 : // software; you can redistribute it and/or modify it under the
           8                 : // terms of the GNU General Public License as published by the
           9                 : // Free Software Foundation; either version 2, or (at your option)
          10                 : // any later version.
          11                 :
          12                 : // This library is distributed in the hope that it will be useful,
          13                 : // but WITHOUT ANY WARRANTY; without even the implied warranty of
          14                 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
          15                 : // GNU General Public License for more details.
          16                 :
          17                 : // You should have received a copy of the GNU General Public License along
          18                 : // with this library; see the file COPYING.  If not, write to the Free
          19                 : // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
          20                 : // USA.
          21                 :
          22                 : // As a special exception, you may use this file as part of a free software
          23                 : // library without restriction.  Specifically, if other files instantiate
          24                 : // templates or use macros or inline functions from this file, or you compile
          25                 : // this file and link it with other files to produce an executable, this
          26                 : // file does not by itself cause the resulting executable to be covered by
          27                 : // the GNU General Public License.  This exception does not however
          28                 : // invalidate any other reasons why the executable file might be covered by
          29                 : // the GNU General Public License.
          30                 :
          31                 : /*
          32                 :  *
          33                 :  * Copyright (c) 1994
          34                 :  * Hewlett-Packard Company
          35                 :  *
          36                 :  * Permission to use, copy, modify, distribute and sell this software
          37                 :  * and its documentation for any purpose is hereby granted without fee,
          38                 :  * provided that the above copyright notice appear in all copies and
          39                 :  * that both that copyright notice and this permission notice appear
          40                 :  * in supporting documentation.  Hewlett-Packard Company makes no
          41                 :  * representations about the suitability of this software for any
          42                 :  * purpose.  It is provided "as is" without express or implied warranty.
          43                 :  *
          44                 :  *
          45                 :  * Copyright (c) 1996,1997
          46                 :  * Silicon Graphics Computer Systems, Inc.
          47                 :  *
          48                 :  * Permission to use, copy, modify, distribute and sell this software
          49                 :  * and its documentation for any purpose is hereby granted without fee,
          50                 :  * provided that the above copyright notice appear in all copies and
          51                 :  * that both that copyright notice and this permission notice appear
          52                 :  * in supporting documentation.  Silicon Graphics makes no
          53                 :  * representations about the suitability of this software for any
          54                 :  * purpose.  It is provided "as is" without express or implied warranty.
          55                 :  */
          56                 :
          57                 : /** @file stl_construct.h
          58                 :  *  This is an internal header file, included by other library headers.
          59                 :  *  You should not attempt to use it directly.
          60                 :  */
          61                 :
          62                 : #ifndef _STL_CONSTRUCT_H
          63                 : #define _STL_CONSTRUCT_H 1
          64                 :
          65                 : #include <new>
          66                 :
          67                 : _GLIBCXX_BEGIN_NAMESPACE(std)
          68                 :
          69                 :   /**
          70                 :    * Constructs an object in existing memory by invoking an allocated
          71                 :    * object's constructor with an initializer.
          72                 :    */
          73                 :   template<typename _T1, typename _T2>
          74                 :     inline void
          75           23695 :     _Construct(_T1* __p, const _T2& __value)
          76                 :     {
          77                 :       // _GLIBCXX_RESOLVE_LIB_DEFECTS
          78                 :       // 402. wrong new expression in [some_]allocator::construct
          79           23695 :       ::new(static_cast<void*>(__p)) _T1(__value);
          80           23695 :     }
          81                 :
          82                 :   /**
          83                 :    * Destroy the object pointed to by a pointer type.
          84                 :    */
          85                 :   template<typename _Tp>
          86                 :     inline void
          87           82748 :     _Destroy(_Tp* __pointer)
          88           82748 :     { __pointer->~_Tp(); }
          89                 :
          90                 :   /**
          91                 :    * Destroy a range of objects.  If the value_type of the object has
          92                 :    * a trivial destructor, the compiler should optimize all of this
          93                 :    * away, otherwise the objects' destructors must be invoked.
          94                 :    */
          95                 :   template<typename _ForwardIterator>
          96                 :     inline void
          97           33441 :     _Destroy(_ForwardIterator __first, _ForwardIterator __last)
          98                 :     {
          99                 :       typedef typename iterator_traits<_ForwardIterator>::value_type
         100                 :                        _Value_type;
         101           91960 :       if (!__has_trivial_destructor(_Value_type))
         102                 :         for (; __first != __last; ++__first)
         103           82748 :           std::_Destroy(&*__first);
         104           33441 :     }
         105                 :
         106                 :   /**
         107                 :    * Destroy a range of objects using the supplied allocator.  For
         108                 :    * nondefault allocators we do not optimize away invocation of
         109                 :    * destroy() even if _Tp has a trivial destructor.
         110                 :    */
         111                 :
         112                 :   template <typename _Tp> class allocator;
         113                 :
         114                 :   template<typename _ForwardIterator, typename _Allocator>
         115                 :     void
         116                 :     _Destroy(_ForwardIterator __first, _ForwardIterator __last,
         117                 :              _Allocator& __alloc)
         118                 :     {
         119                 :       for (; __first != __last; ++__first)
         120                 :         __alloc.destroy(&*__first);
         121                 :     }
         122                 :
         123                 :   template<typename _ForwardIterator, typename _Tp>
         124                 :     inline void
         125                 :     _Destroy(_ForwardIterator __first, _ForwardIterator __last,
         126           33441 :              allocator<_Tp>&)
         127                 :     {
         128           33441 :       _Destroy(__first, __last);
         129           33441 :     }
         130                 :
         131                 : _GLIBCXX_END_NAMESPACE
         132                 :
         133                 : #endif /* _STL_CONSTRUCT_H */
         134                 :

Generated by: LTP GCOV extension version 1.6