libstdc++
stl_raw_storage_iter.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010
00004 // Free Software Foundation, Inc.
00005 //
00006 // This file is part of the GNU ISO C++ Library.  This library is free
00007 // software; you can redistribute it and/or modify it under the
00008 // terms of the GNU General Public License as published by the
00009 // Free Software Foundation; either version 3, or (at your option)
00010 // any later version.
00011 
00012 // This library is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 
00017 // Under Section 7 of GPL version 3, you are granted additional
00018 // permissions described in the GCC Runtime Library Exception, version
00019 // 3.1, as published by the Free Software Foundation.
00020 
00021 // You should have received a copy of the GNU General Public License and
00022 // a copy of the GCC Runtime Library Exception along with this program;
00023 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00024 // <http://www.gnu.org/licenses/>.
00025 
00026 /*
00027  *
00028  * Copyright (c) 1994
00029  * Hewlett-Packard Company
00030  *
00031  * Permission to use, copy, modify, distribute and sell this software
00032  * and its documentation for any purpose is hereby granted without fee,
00033  * provided that the above copyright notice appear in all copies and
00034  * that both that copyright notice and this permission notice appear
00035  * in supporting documentation.  Hewlett-Packard Company makes no
00036  * representations about the suitability of this software for any
00037  * purpose.  It is provided "as is" without express or implied warranty.
00038  *
00039  *
00040  * Copyright (c) 1996
00041  * Silicon Graphics Computer Systems, Inc.
00042  *
00043  * Permission to use, copy, modify, distribute and sell this software
00044  * and its documentation for any purpose is hereby granted without fee,
00045  * provided that the above copyright notice appear in all copies and
00046  * that both that copyright notice and this permission notice appear
00047  * in supporting documentation.  Silicon Graphics makes no
00048  * representations about the suitability of this software for any
00049  * purpose.  It is provided "as is" without express or implied warranty.
00050  */
00051 
00052 /** @file bits/stl_raw_storage_iter.h
00053  *  This is an internal header file, included by other library headers.
00054  *  Do not attempt to use it directly. @headername{memory}
00055  */
00056 
00057 #ifndef _STL_RAW_STORAGE_ITERATOR_H
00058 #define _STL_RAW_STORAGE_ITERATOR_H 1
00059 
00060 namespace std _GLIBCXX_VISIBILITY(default)
00061 {
00062 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00063 
00064   /**
00065    *  This iterator class lets algorithms store their results into
00066    *  uninitialized memory.
00067   */
00068   template <class _OutputIterator, class _Tp>
00069     class raw_storage_iterator
00070     : public iterator<output_iterator_tag, void, void, void, void>
00071     {
00072     protected:
00073       _OutputIterator _M_iter;
00074 
00075     public:
00076       explicit
00077       raw_storage_iterator(_OutputIterator __x)
00078       : _M_iter(__x) {}
00079 
00080       raw_storage_iterator&
00081       operator*() { return *this; }
00082 
00083       raw_storage_iterator&
00084       operator=(const _Tp& __element)
00085       {
00086     std::_Construct(std::__addressof(*_M_iter), __element);
00087     return *this;
00088       }
00089 
00090       raw_storage_iterator<_OutputIterator, _Tp>&
00091       operator++()
00092       {
00093     ++_M_iter;
00094     return *this;
00095       }
00096 
00097       raw_storage_iterator<_OutputIterator, _Tp>
00098       operator++(int)
00099       {
00100     raw_storage_iterator<_OutputIterator, _Tp> __tmp = *this;
00101     ++_M_iter;
00102     return __tmp;
00103       }
00104     };
00105 
00106 _GLIBCXX_END_NAMESPACE_VERSION
00107 } // namespace
00108 
00109 #endif