]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/include/bits/stl_construct.h
Update copyright years in libstdc++-v3/
[thirdparty/gcc.git] / libstdc++-v3 / include / bits / stl_construct.h
index 0366eec69c73d699c7ba139ef657547655f35c67..df245c7eb4b8ac7129cf805e27b0121e78e1535e 100644 (file)
@@ -1,7 +1,6 @@
 // nonstandard construct and destroy functions -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
-// Free Software Foundation, Inc.
+// Copyright (C) 2001-2014 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
  * purpose.  It is provided "as is" without express or implied warranty.
  */
 
-/** @file stl_construct.h
+/** @file bits/stl_construct.h
  *  This is an internal header file, included by other library headers.
- *  You should not attempt to use it directly.
+ *  Do not attempt to use it directly. @headername{memory}
  */
 
 #ifndef _STL_CONSTRUCT_H
 #define _STL_CONSTRUCT_H 1
 
 #include <new>
+#include <bits/move.h>
+#include <ext/alloc_traits.h>
 
-_GLIBCXX_BEGIN_NAMESPACE(std)
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   /**
    * Constructs an object in existing memory by invoking an allocated
    * object's constructor with an initializer.
    */
-  template<typename _T1, typename _T2>
+#if __cplusplus >= 201103L
+  template<typename _T1, typename... _Args>
     inline void
-#ifdef __GXX_EXPERIMENTAL_CXX0X__
-    // Allow perfect forwarding
-    _Construct(_T1* __p, _T2&& __value)
+    _Construct(_T1* __p, _Args&&... __args)
+    { ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...); }
 #else
+  template<typename _T1, typename _T2>
+    inline void
     _Construct(_T1* __p, const _T2& __value)
-#endif
     {
       // _GLIBCXX_RESOLVE_LIB_DEFECTS
       // 402. wrong new expression in [some_]allocator::construct
-      ::new(static_cast<void*>(__p)) _T1(_GLIBCXX_FORWARD(_T2, __value));
+      ::new(static_cast<void*>(__p)) _T1(__value);
     }
+#endif
 
   /**
    * Destroy the object pointed to by a pointer type.
@@ -95,7 +100,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
         __destroy(_ForwardIterator __first, _ForwardIterator __last)
        {
          for (; __first != __last; ++__first)
-           std::_Destroy(&*__first);
+           std::_Destroy(std::__addressof(*__first));
        }
     };
 
@@ -128,15 +133,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
    * destroy() even if _Tp has a trivial destructor.
    */
 
-  template <typename _Tp> class allocator;
-
   template<typename _ForwardIterator, typename _Allocator>
     void
     _Destroy(_ForwardIterator __first, _ForwardIterator __last,
             _Allocator& __alloc)
     {
+      typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
       for (; __first != __last; ++__first)
-       __alloc.destroy(&*__first);
+       __traits::destroy(__alloc, std::__addressof(*__first));
     }
 
   template<typename _ForwardIterator, typename _Tp>
@@ -147,7 +151,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       _Destroy(__first, __last);
     }
 
-_GLIBCXX_END_NAMESPACE
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
 
 #endif /* _STL_CONSTRUCT_H */