|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r54295 - in sandbox/monotonic: boost/monotonic boost/monotonic/container libs/monotonic/test/Tests
From: christian.schladetsch_at_[hidden]
Date: 2009-06-23 19:37:31
Author: cschladetsch
Date: 2009-06-23 19:37:30 EDT (Tue, 23 Jun 2009)
New Revision: 54295
URL: http://svn.boost.org/trac/boost/changeset/54295
Log:
updated tests
Text files modified:
sandbox/monotonic/boost/monotonic/allocator_base.hpp | 5 +++--
sandbox/monotonic/boost/monotonic/container/string.hpp | 29 +++++++++++++++++++++--------
sandbox/monotonic/libs/monotonic/test/Tests/tests.cpp | 23 ++++++++++++++++++++++-
3 files changed, 46 insertions(+), 11 deletions(-)
Modified: sandbox/monotonic/boost/monotonic/allocator_base.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/allocator_base.hpp (original)
+++ sandbox/monotonic/boost/monotonic/allocator_base.hpp 2009-06-23 19:37:30 EDT (Tue, 23 Jun 2009)
@@ -33,6 +33,7 @@
typedef T &reference;
typedef const T &const_reference;
typedef T value_type;
+ typedef detail::Construct<detail::is_monotonic<T>::value> Construct;
BOOST_STATIC_CONSTANT(size_t, alignment = boost::aligned_storage<sizeof(T)>::alignment);
//private:
@@ -81,13 +82,13 @@
void construct(pointer ptr)
{
- detail::Construct<detail::is_monotonic<T>::value>::Given(ptr, static_cast<Derived *>(this));
+ Construct::Given(ptr, static_cast<Derived *>(this));
//new (ptr) T();
}
void construct(pointer ptr, const T& val)
{
- detail::Construct<detail::is_monotonic<T>::value>::Given(ptr, val, static_cast<Derived *>(this));
+ Construct::Given(ptr, val, static_cast<Derived *>(this));
//new (ptr) T(val);
}
Modified: sandbox/monotonic/boost/monotonic/container/string.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/container/string.hpp (original)
+++ sandbox/monotonic/boost/monotonic/container/string.hpp 2009-06-23 19:37:30 EDT (Tue, 23 Jun 2009)
@@ -15,7 +15,7 @@
{
/// a string that uses a monotonic allocator in the given region
template <class Region = default_region_tag, class Access = default_access_tag>
- struct string
+ struct string : detail::container<string<Region,Access> >
{
typedef char Ch;
typedef std::char_traits<Ch> Tr;
@@ -51,6 +51,10 @@
: impl(str, alloc)
{
}
+ string(const Ch *str, storage_base &store)
+ : impl(str, store)
+ {
+ }
template <class II>
string(II F, II L)
: impl(F, L)
@@ -61,6 +65,22 @@
: impl(F, L, alloc)
{
}
+ template <class II>
+ string(II F, II L, storage_base &store)
+ : impl(F, L, store)
+ {
+ }
+
+ string &operator=(string const &other)
+ {
+ impl = other.get_impl();
+ return *this;
+ }
+
+ Allocator get_allocator() const
+ {
+ return impl.get_allocator();
+ }
Impl const &get_impl() const
{
@@ -71,12 +91,6 @@
return impl;
}
- string &operator=(string const &other)
- {
- impl = other.get_impl();
- return *this;
- }
-
template <class Reg2, class Acc2>
string &operator=(string<Reg2,Acc2> const &other)
{
@@ -94,7 +108,6 @@
{
return impl.c_str();
}
-
};
template <class Reg, class Acc>
Modified: sandbox/monotonic/libs/monotonic/test/Tests/tests.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/Tests/tests.cpp (original)
+++ sandbox/monotonic/libs/monotonic/test/Tests/tests.cpp 2009-06-23 19:37:30 EDT (Tue, 23 Jun 2009)
@@ -42,6 +42,13 @@
monotonic::static_storage<>::release();
monotonic::static_storage<region0>::release();
monotonic::static_storage<region1>::release();
+
+ monotonic::storage<> storage;
+ {
+ monotonic::string<> str("foo", storage);
+ BOOST_ASSERT(str == "foo");
+ BOOST_ASSERT(str.get_allocator().get_storage() == &storage);
+ }
}
BOOST_AUTO_TEST_CASE(test_map)
@@ -85,9 +92,23 @@
BOOST_ASSERT(vec2 < vec);
BOOST_ASSERT(!(vec < vec2));
-
monotonic::static_storage<>::reset();
monotonic::static_storage<region1>::reset();
+
+ monotonic::storage<> storage;
+ {
+ monotonic::vector<monotonic::vector<int> > vec(storage);
+ BOOST_ASSERT(vec.get_allocator().get_storage() == &storage);
+ vec.resize(5);
+ BOOST_ASSERT(vec[0].get_allocator().get_storage() == &storage);
+
+ monotonic::vector<monotonic::map<int, monotonic::string<> > > vec2(storage);
+ vec2.resize(1);
+ vec2[0][42] = "foo";
+ BOOST_ASSERT(vec2.get_allocator().get_storage() == &storage);
+ BOOST_ASSERT(vec2[0].get_allocator().get_storage() == &storage);
+ BOOST_ASSERT(vec2[0][42].get_allocator().get_storage() == &storage);
+ }
}
template <class II>
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