Commit 61fcb9fb by Paolo Carlini Committed by Paolo Carlini

throw_allocator.h (throw_allocator<>:: construct<>(pointer, _Args&&...)): Add.

2007-10-26  Paolo Carlini  <pcarlini@suse.de>

	* include/ext/throw_allocator.h (throw_allocator<>::
	construct<>(pointer, _Args&&...)): Add.
	* include/ext/pool_allocator.h (__pool_alloc<>::
	construct<>(pointer, _Args&&...)): Likewise.
	(construct(pointer, const _Tp&)): Cast pointer to void*. 
	* include/ext/bitmap_allocator.h (bitmap_allocator<>::
	construct<>(pointer, _Args&&...)): Add.
	(construct(pointer, const _Tp&)): Cast pointer to void*.
	* include/ext/new_allocator.h (new_allocator<>::
	construct<>(pointer, _Args&&...)): Add.
	(construct(pointer, const _Tp&)): Cast pointer to void*.
	* include/ext/malloc_allocator.h (malloc_allocator<>::
	construct<>(pointer, _Args&&...)): Add.
	(construct(pointer, const _Tp&)): Cast pointer to void*.
	* include/ext/array_allocator.h (array_allocator<>::
	construct<>(pointer, _Args&&...)): Add.
	(construct(pointer, const _Tp&)): Cast pointer to void*.
	* include/ext/mt_allocator.h (__mt_alloc<>::
	construct<>(pointer, _Args&&...)): Add.
	(construct(pointer, const _Tp&)): Cast pointer to void*.
	* testsuite/util/testsuite_allocator.h (tracker_allocator<>::
	construct<>(pointer, _Args&&...)): Add.
	(construct(pointer, const _Tp&)): Cast pointer to void*.
 	(uneq_allocator<>::construct<>(pointer, _Args&&...)): Add.
	(construct(pointer, const _Tp&)): Cast pointer to void*.
	* testsuite/ext/mt_allocator/variadic_construct.cc: New.
	* testsuite/ext/new_allocator/variadic_construct.cc: Likewise.
	* testsuite/ext/throw_allocator/variadic_construct.cc: Likewise.
	* testsuite/ext/malloc_allocator/variadic_construct.cc: Likewise.
	* testsuite/ext/pool_allocator/variadic_construct.cc: Likewise.
	* testsuite/ext/bitmap_allocator/variadic_construct.cc: Likewise.
	* testsuite/ext/array_allocator/variadic_construct.cc: Likewise.

From-SVN: r129672
parent 00e65cfa
2007-10-26 Paolo Carlini <pcarlini@suse.de>
* include/ext/throw_allocator.h (throw_allocator<>::
construct<>(pointer, _Args&&...)): Add.
* include/ext/pool_allocator.h (__pool_alloc<>::
construct<>(pointer, _Args&&...)): Likewise.
(construct(pointer, const _Tp&)): Cast pointer to void*.
* include/ext/bitmap_allocator.h (bitmap_allocator<>::
construct<>(pointer, _Args&&...)): Add.
(construct(pointer, const _Tp&)): Cast pointer to void*.
* include/ext/new_allocator.h (new_allocator<>::
construct<>(pointer, _Args&&...)): Add.
(construct(pointer, const _Tp&)): Cast pointer to void*.
* include/ext/malloc_allocator.h (malloc_allocator<>::
construct<>(pointer, _Args&&...)): Add.
(construct(pointer, const _Tp&)): Cast pointer to void*.
* include/ext/array_allocator.h (array_allocator<>::
construct<>(pointer, _Args&&...)): Add.
(construct(pointer, const _Tp&)): Cast pointer to void*.
* include/ext/mt_allocator.h (__mt_alloc<>::
construct<>(pointer, _Args&&...)): Add.
(construct(pointer, const _Tp&)): Cast pointer to void*.
* testsuite/util/testsuite_allocator.h (tracker_allocator<>::
construct<>(pointer, _Args&&...)): Add.
(construct(pointer, const _Tp&)): Cast pointer to void*.
(uneq_allocator<>::construct<>(pointer, _Args&&...)): Add.
(construct(pointer, const _Tp&)): Cast pointer to void*.
* testsuite/ext/mt_allocator/variadic_construct.cc: New.
* testsuite/ext/new_allocator/variadic_construct.cc: Likewise.
* testsuite/ext/throw_allocator/variadic_construct.cc: Likewise.
* testsuite/ext/malloc_allocator/variadic_construct.cc: Likewise.
* testsuite/ext/pool_allocator/variadic_construct.cc: Likewise.
* testsuite/ext/bitmap_allocator/variadic_construct.cc: Likewise.
* testsuite/ext/array_allocator/variadic_construct.cc: Likewise.
2007-10-26 Benjamin Kosnik <bkoz@redhat.com> 2007-10-26 Benjamin Kosnik <bkoz@redhat.com>
* include/std/unordered_map: Fix for parallel mode. * include/std/unordered_map: Fix for parallel mode.
......
// array allocator -*- C++ -*- // array allocator -*- C++ -*-
// Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. // Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <new> #include <new>
#include <bits/functexcept.h> #include <bits/functexcept.h>
#include <tr1/array> #include <tr1/array>
#include <bits/stl_move.h>
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
...@@ -77,7 +78,14 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -77,7 +78,14 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
// 402. wrong new expression in [some_] allocator::construct // 402. wrong new expression in [some_] allocator::construct
void void
construct(pointer __p, const _Tp& __val) construct(pointer __p, const _Tp& __val)
{ ::new(__p) value_type(__val); } { ::new((void *)__p) value_type(__val); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename... _Args>
void
construct(pointer __p, _Args&&... __args)
{ ::new((void *)__p) _Tp(std::forward<_Args>(__args)...); }
#endif
void void
destroy(pointer __p) { __p->~_Tp(); } destroy(pointer __p) { __p->~_Tp(); }
......
// Bitmap Allocator. -*- C++ -*- // Bitmap Allocator. -*- C++ -*-
// Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. // Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
#include <new> // For operator new. #include <new> // For operator new.
#include <debug/debug.h> // _GLIBCXX_DEBUG_ASSERT #include <debug/debug.h> // _GLIBCXX_DEBUG_ASSERT
#include <ext/concurrence.h> #include <ext/concurrence.h>
#include <bits/stl_move.h>
/** @brief The constant in the expression below is the alignment /** @brief The constant in the expression below is the alignment
* required in bytes. * required in bytes.
...@@ -1089,7 +1089,14 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -1089,7 +1089,14 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
void void
construct(pointer __p, const_reference __data) construct(pointer __p, const_reference __data)
{ ::new(__p) value_type(__data); } { ::new((void *)__p) value_type(__data); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename... _Args>
void
construct(pointer __p, _Args&&... __args)
{ ::new((void *)__p) _Tp(std::forward<_Args>(__args)...); }
#endif
void void
destroy(pointer __p) destroy(pointer __p)
......
// Allocator that wraps "C" malloc -*- C++ -*- // Allocator that wraps "C" malloc -*- C++ -*-
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <cstdlib> #include <cstdlib>
#include <new> #include <new>
#include <bits/functexcept.h> #include <bits/functexcept.h>
#include <bits/stl_move.h>
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
...@@ -109,7 +110,14 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -109,7 +110,14 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
// 402. wrong new expression in [some_] allocator::construct // 402. wrong new expression in [some_] allocator::construct
void void
construct(pointer __p, const _Tp& __val) construct(pointer __p, const _Tp& __val)
{ ::new(__p) value_type(__val); } { ::new((void *)__p) value_type(__val); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename... _Args>
void
construct(pointer __p, _Args&&... __args)
{ ::new((void *)__p) _Tp(std::forward<_Args>(__args)...); }
#endif
void void
destroy(pointer __p) { __p->~_Tp(); } destroy(pointer __p) { __p->~_Tp(); }
......
// MT-optimized allocator -*- C++ -*- // MT-optimized allocator -*- C++ -*-
// Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. // Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <cstdlib> #include <cstdlib>
#include <bits/functexcept.h> #include <bits/functexcept.h>
#include <ext/atomicity.h> #include <ext/atomicity.h>
#include <bits/stl_move.h>
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
...@@ -593,7 +594,14 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -593,7 +594,14 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
// 402. wrong new expression in [some_] allocator::construct // 402. wrong new expression in [some_] allocator::construct
void void
construct(pointer __p, const _Tp& __val) construct(pointer __p, const _Tp& __val)
{ ::new(__p) _Tp(__val); } { ::new((void *)__p) _Tp(__val); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename... _Args>
void
construct(pointer __p, _Args&&... __args)
{ ::new((void *)__p) _Tp(std::forward<_Args>(__args)...); }
#endif
void void
destroy(pointer __p) { __p->~_Tp(); } destroy(pointer __p) { __p->~_Tp(); }
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <new> #include <new>
#include <bits/functexcept.h> #include <bits/functexcept.h>
#include <bits/stl_move.h>
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
...@@ -104,7 +105,14 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -104,7 +105,14 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
// 402. wrong new expression in [some_] allocator::construct // 402. wrong new expression in [some_] allocator::construct
void void
construct(pointer __p, const _Tp& __val) construct(pointer __p, const _Tp& __val)
{ ::new(__p) _Tp(__val); } { ::new((void *)__p) _Tp(__val); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename... _Args>
void
construct(pointer __p, _Args&&... __args)
{ ::new((void *)__p) _Tp(std::forward<_Args>(__args)...); }
#endif
void void
destroy(pointer __p) { __p->~_Tp(); } destroy(pointer __p) { __p->~_Tp(); }
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#include <bits/functexcept.h> #include <bits/functexcept.h>
#include <ext/atomicity.h> #include <ext/atomicity.h>
#include <ext/concurrence.h> #include <ext/concurrence.h>
#include <bits/stl_move.h>
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
...@@ -164,7 +165,14 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -164,7 +165,14 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
// 402. wrong new expression in [some_] allocator::construct // 402. wrong new expression in [some_] allocator::construct
void void
construct(pointer __p, const _Tp& __val) construct(pointer __p, const _Tp& __val)
{ ::new(__p) _Tp(__val); } { ::new((void *)__p) _Tp(__val); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename... _Args>
void
construct(pointer __p, _Args&&... __args)
{ ::new((void *)__p) _Tp(std::forward<_Args>(__args)...); }
#endif
void void
destroy(pointer __p) { __p->~_Tp(); } destroy(pointer __p) { __p->~_Tp(); }
......
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
#include <utility> #include <utility>
#include <tr1/random> #include <tr1/random>
#include <bits/functexcept.h> #include <bits/functexcept.h>
#include <bits/stl_move.h>
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
...@@ -232,6 +233,16 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -232,6 +233,16 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
construct(pointer __p, const T& val) construct(pointer __p, const T& val)
{ return std::allocator<value_type>().construct(__p, val); } { return std::allocator<value_type>().construct(__p, val); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename... _Args>
void
construct(pointer __p, _Args&&... __args)
{
return std::allocator<value_type>().
construct(__p, std::forward<_Args>(__args)...);
}
#endif
void void
destroy(pointer __p) destroy(pointer __p)
{ std::allocator<value_type>().destroy(__p); } { std::allocator<value_type>().destroy(__p); }
......
// { dg-options "-std=gnu++0x" }
// 2007-10-27 Paolo Carlini <pcarlini@suse.de>
// Copyright (C) 2007 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// 20.4.1.1 allocator members
#include <ext/array_allocator.h>
#include <utility>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef std::pair<int, char> pair_type;
typedef std::tr1::array<pair_type, 3> array_type;
array_type store;
__gnu_cxx::array_allocator<pair_type, array_type> alloc1(&store);
pair_type* ptp1 = alloc1.allocate(1);
alloc1.construct(ptp1, 3, 'a');
VERIFY( ptp1->first == 3 );
VERIFY( ptp1->second == 'a' );
alloc1.deallocate(ptp1, 1);
}
int main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++0x" }
// 2007-10-26 Paolo Carlini <pcarlini@suse.de>
// Copyright (C) 2007 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
#include <ext/bitmap_allocator.h>
#include <utility>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef std::pair<int, char> pair_type;
__gnu_cxx::bitmap_allocator<pair_type> alloc1;
pair_type* ptp1 = alloc1.allocate(1);
alloc1.construct(ptp1, 3, 'a');
VERIFY( ptp1->first == 3 );
VERIFY( ptp1->second == 'a' );
alloc1.deallocate(ptp1, 1);
}
int main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++0x" }
// 2007-10-26 Paolo Carlini <pcarlini@suse.de>
// Copyright (C) 2007 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
#include <ext/malloc_allocator.h>
#include <utility>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef std::pair<int, char> pair_type;
__gnu_cxx::malloc_allocator<pair_type> alloc1;
pair_type* ptp1 = alloc1.allocate(1);
alloc1.construct(ptp1, 3, 'a');
VERIFY( ptp1->first == 3 );
VERIFY( ptp1->second == 'a' );
alloc1.deallocate(ptp1, 1);
}
int main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++0x" }
// 2007-10-26 Paolo Carlini <pcarlini@suse.de>
// Copyright (C) 2007 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
#include <ext/mt_allocator.h>
#include <utility>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef std::pair<int, char> pair_type;
__gnu_cxx::__mt_alloc<pair_type> alloc1;
pair_type* ptp1 = alloc1.allocate(1);
alloc1.construct(ptp1, 3, 'a');
VERIFY( ptp1->first == 3 );
VERIFY( ptp1->second == 'a' );
alloc1.deallocate(ptp1, 1);
}
int main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++0x" }
// 2007-10-26 Paolo Carlini <pcarlini@suse.de>
// Copyright (C) 2007 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
#include <ext/new_allocator.h>
#include <utility>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef std::pair<int, char> pair_type;
__gnu_cxx::new_allocator<pair_type> alloc1;
pair_type* ptp1 = alloc1.allocate(1);
alloc1.construct(ptp1, 3, 'a');
VERIFY( ptp1->first == 3 );
VERIFY( ptp1->second == 'a' );
alloc1.deallocate(ptp1, 1);
}
int main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++0x" }
// 2007-10-26 Paolo Carlini <pcarlini@suse.de>
// Copyright (C) 2007 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
#include <ext/pool_allocator.h>
#include <utility>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef std::pair<int, char> pair_type;
__gnu_cxx::__pool_alloc<pair_type> alloc1;
pair_type* ptp1 = alloc1.allocate(1);
alloc1.construct(ptp1, 3, 'a');
VERIFY( ptp1->first == 3 );
VERIFY( ptp1->second == 'a' );
alloc1.deallocate(ptp1, 1);
}
int main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++0x" }
// 2007-10-26 Paolo Carlini <pcarlini@suse.de>
// Copyright (C) 2007 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
#include <ext/throw_allocator.h>
#include <utility>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef std::pair<int, char> pair_type;
__gnu_cxx::throw_allocator<pair_type> alloc1;
pair_type* ptp1 = alloc1.allocate(1);
alloc1.construct(ptp1, 3, 'a');
VERIFY( ptp1->first == 3 );
VERIFY( ptp1->second == 'a' );
alloc1.deallocate(ptp1, 1);
}
int main()
{
test01();
return 0;
}
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <cstddef> #include <cstddef>
#include <tr1/unordered_map> #include <tr1/unordered_map>
#include <cassert> #include <cassert>
#include <bits/stl_move.h>
namespace namespace
{ {
...@@ -153,10 +154,20 @@ namespace __gnu_test ...@@ -153,10 +154,20 @@ namespace __gnu_test
void void
construct(pointer p, const T& value) construct(pointer p, const T& value)
{ {
new (p) T(value); ::new ((void *)p) T(value);
counter_type::construct(); counter_type::construct();
} }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename... Args>
void
construct(pointer p, Args&&... args)
{
::new((void *)p) T(std::forward<Args>(args)...);
counter_type::construct();
}
#endif
void void
destroy(pointer p) destroy(pointer p)
{ {
...@@ -338,8 +349,15 @@ namespace __gnu_test ...@@ -338,8 +349,15 @@ namespace __gnu_test
void void
construct(pointer p, const Tp& val) construct(pointer p, const Tp& val)
{ ::new(p) Tp(val); } { ::new((void *)p) Tp(val); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename... Args>
void
construct(pointer p, Args&&... args)
{ ::new((void *)p) Tp(std::forward<Args>(args)...); }
#endif
void void
destroy(pointer p) { p->~Tp(); } destroy(pointer p) { p->~Tp(); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment