libstdc++
stl_raw_storage_iter.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // Copyright (C) 2001-2015 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
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 3, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU 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 /*
00026  *
00027  * Copyright (c) 1994
00028  * Hewlett-Packard Company
00029  *
00030  * Permission to use, copy, modify, distribute and sell this software
00031  * and its documentation for any purpose is hereby granted without fee,
00032  * provided that the above copyright notice appear in all copies and
00033  * that both that copyright notice and this permission notice appear
00034  * in supporting documentation.  Hewlett-Packard Company makes no
00035  * representations about the suitability of this software for any
00036  * purpose.  It is provided "as is" without express or implied warranty.
00037  *
00038  *
00039  * Copyright (c) 1996
00040  * Silicon Graphics Computer Systems, Inc.
00041  *
00042  * Permission to use, copy, modify, distribute and sell this software
00043  * and its documentation for any purpose is hereby granted without fee,
00044  * provided that the above copyright notice appear in all copies and
00045  * that both that copyright notice and this permission notice appear
00046  * in supporting documentation.  Silicon Graphics makes no
00047  * representations about the suitability of this software for any
00048  * purpose.  It is provided "as is" without express or implied warranty.
00049  */
00050 
00051 /** @file bits/stl_raw_storage_iter.h
00052  *  This is an internal header file, included by other library headers.
00053  *  Do not attempt to use it directly. @headername{memory}
00054  */
00055 
00056 #ifndef _STL_RAW_STORAGE_ITERATOR_H
00057 #define _STL_RAW_STORAGE_ITERATOR_H 1
00058 
00059 namespace std _GLIBCXX_VISIBILITY(default)
00060 {
00061 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00062 
00063   /**
00064    *  This iterator class lets algorithms store their results into
00065    *  uninitialized memory.
00066   */
00067   template <class _OutputIterator, class _Tp>
00068     class raw_storage_iterator
00069     : public iterator<output_iterator_tag, void, void, void, void>
00070     {
00071     protected:
00072       _OutputIterator _M_iter;
00073 
00074     public:
00075       explicit
00076       raw_storage_iterator(_OutputIterator __x)
00077       : _M_iter(__x) {}
00078 
00079       raw_storage_iterator&
00080       operator*() { return *this; }
00081 
00082       raw_storage_iterator&
00083       operator=(const _Tp& __element)
00084       {
00085         std::_Construct(std::__addressof(*_M_iter), __element);
00086         return *this;
00087       }
00088 
00089       raw_storage_iterator<_OutputIterator, _Tp>&
00090       operator++()
00091       {
00092         ++_M_iter;
00093         return *this;
00094       }
00095 
00096       raw_storage_iterator<_OutputIterator, _Tp>
00097       operator++(int)
00098       {
00099         raw_storage_iterator<_OutputIterator, _Tp> __tmp = *this;
00100         ++_M_iter;
00101         return __tmp;
00102       }
00103     };
00104 
00105 _GLIBCXX_END_NAMESPACE_VERSION
00106 } // namespace
00107 
00108 #endif