* [v3] update testsuite allocators to C++0x allocator API
@ 2011-06-04 17:18 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2011-06-04 17:18 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 522 bytes --]
2011-06-04 Jonathan Wakely <jwakely.gcc@gmail.com>
* testsuite/util/testsuite_allocator.h (tracker_allocator::construct):
Update to C++0x definition using type to construct as template
parameter.
(tracker_allocator::destroy): Likewise for type to destroy.
(uneq_allocator::construct, uneq_allocator::destroy): Likewise.
I updated the various v3 allocators to use the C++0x API last week,
this does the same for the two test allocators.
Tested x86_64-linux, committed to trunk.
[-- Attachment #2: test-allocs.txt --]
[-- Type: text/plain, Size: 2559 bytes --]
Index: testsuite/util/testsuite_allocator.h
===================================================================
--- testsuite/util/testsuite_allocator.h (revision 174624)
+++ testsuite/util/testsuite_allocator.h (working copy)
@@ -138,6 +138,23 @@ namespace __gnu_test
allocate(size_type n, const void* = 0)
{ return static_cast<pointer>(counter_type::allocate(n * sizeof(T))); }
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ template<typename U, typename... Args>
+ void
+ construct(U* p, Args&&... args)
+ {
+ ::new((void *)p) U(std::forward<Args>(args)...);
+ counter_type::construct();
+ }
+
+ template<typename U>
+ void
+ destroy(U* p)
+ {
+ p->~U();
+ counter_type::destroy();
+ }
+#else
void
construct(pointer p, const T& value)
{
@@ -145,22 +162,13 @@ namespace __gnu_test
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
destroy(pointer p)
{
p->~T();
counter_type::destroy();
}
+#endif
void
deallocate(pointer p, size_type num)
@@ -313,34 +321,35 @@ namespace __gnu_test
max_size() const throw()
{ return size_type(-1) / sizeof(Tp); }
- void
- construct(pointer p, const Tp& val)
- { ::new((void *)p) Tp(val); }
-
#ifdef __GXX_EXPERIMENTAL_CXX0X__
- template<typename... Args>
+ template<typename U, typename... Args>
void
- construct(pointer p, Args&&... args)
- { ::new((void *)p) Tp(std::forward<Args>(args)...); }
-#endif
+ construct(U* p, Args&&... args)
+ { ::new((void *)p) U(std::forward<Args>(args)...); }
- void
- destroy(pointer p) { p->~Tp(); }
+ template<typename U>
+ void
+ destroy(U* p) { p->~U(); }
-#ifdef __GXX_EXPERIMENTAL_CXX0X__
// Not copy assignable...
uneq_allocator&
operator=(const uneq_allocator&) = delete;
-#endif
+#else
+ void
+ construct(pointer p, const Tp& val)
+ { ::new((void *)p) Tp(val); }
- private:
+ void
+ destroy(pointer p) { p->~Tp(); }
-#ifndef __GXX_EXPERIMENTAL_CXX0X__
+ private:
// Not assignable...
uneq_allocator&
operator=(const uneq_allocator&);
#endif
+ private:
+
// ... yet swappable!
friend inline void
swap(uneq_allocator& a, uneq_allocator& b)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-06-04 17:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-04 17:18 [v3] update testsuite allocators to C++0x allocator API Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).