|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r54180 - in sandbox/monotonic: boost/monotonic libs/monotonic/test
From: christian.schladetsch_at_[hidden]
Date: 2009-06-22 02:01:21
Author: cschladetsch
Date: 2009-06-22 02:01:21 EDT (Mon, 22 Jun 2009)
New Revision: 54180
URL: http://svn.boost.org/trac/boost/changeset/54180
Log:
changed mini-stack to use references
Text files modified:
sandbox/monotonic/boost/monotonic/storage.hpp | 14 ++++++--------
sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp | 9 +++------
2 files changed, 9 insertions(+), 14 deletions(-)
Modified: sandbox/monotonic/boost/monotonic/storage.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/storage.hpp (original)
+++ sandbox/monotonic/boost/monotonic/storage.hpp 2009-06-22 02:01:21 EDT (Mon, 22 Jun 2009)
@@ -178,27 +178,25 @@
}
template <class Ty>
- Ty *create()
+ Ty &create()
{
Ty *ptr = initialised_create<Ty>();
new (ptr) Ty();
- return ptr;
+ return *ptr;
}
template <class Ty>
- Ty *create(Ty const &X)
+ Ty &create(Ty const &X)
{
Ty *ptr = initialised_create<Ty>();
new (ptr) Ty(X);
- return ptr;
+ return *ptr;
}
template <class Ty>
- void destroy(Ty *ptr)
+ void destroy(Ty &object)
{
- if (!ptr)
- return;
- ptr->~Ty();
+ object.~Ty();
}
template <size_t N>
Modified: sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp (original)
+++ sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp 2009-06-22 02:01:21 EDT (Mon, 22 Jun 2009)
@@ -445,14 +445,11 @@
for (size_t n = 0; n < length; ++n)
{
// create a new int from storage
- int *n0 = storage.create<int>();
-
- // pass a ctor argument
- int *n1 = storage.create<int>(42);
+ int &n0 = storage.create<int>();
// create a new string (uses correct alignment)
- string *s1 = storage.create<string>("foo");
- BOOST_ASSERT(*s1 == "foo");
+ string &s1 = storage.create<string>("foo");
+ BOOST_ASSERT(s1 == "foo");
// allocate 37 bytes with alignment 1
char *array0 = storage.allocate_bytes(37);
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk