|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r54009 - in sandbox/monotonic: boost/monotonic libs/monotonic/test
From: christian.schladetsch_at_[hidden]
Date: 2009-06-17 05:54:23
Author: cschladetsch
Date: 2009-06-17 05:54:23 EDT (Wed, 17 Jun 2009)
New Revision: 54009
URL: http://svn.boost.org/trac/boost/changeset/54009
Log:
fix for IsMonotonic<T>
Text files modified:
sandbox/monotonic/boost/monotonic/container.hpp | 13 ++++++-------
sandbox/monotonic/libs/monotonic/test/main.cpp | 14 ++++++++++----
2 files changed, 16 insertions(+), 11 deletions(-)
Modified: sandbox/monotonic/boost/monotonic/container.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/container.hpp (original)
+++ sandbox/monotonic/boost/monotonic/container.hpp 2009-06-17 05:54:23 EDT (Wed, 17 Jun 2009)
@@ -18,27 +18,26 @@
{
namespace detail
{
- template <bool, class T>
- struct Creator;
+ struct MonotonicContainerBase { virtual ~MonotonicContainerBase() { } };
template <class Impl>
struct MonotonicContainer;
- template <class>
- struct IsMonotonic : boost::mpl::false_ { };
-
+ template <class T>
+ struct IsMonotonic : boost::mpl::bool_<is_convertible<T *, MonotonicContainerBase *>::value> { };
+
template <class Impl>
struct IsMonotonic<MonotonicContainer<Impl> > : boost::mpl::true_ { };
template <class Impl>
- struct MonotonicContainer
+ struct MonotonicContainer : MonotonicContainerBase
{
typedef Impl Derived;
virtual ~MonotonicContainer() { }
storage_base &GetStorage() const
{
- Derived const &self = dynamic_cast<Derived const &>(*this);
+ Derived const &self = static_cast<Derived const &>(*this);
storage_base *store = self.get_allocator().get_storage();
if (store == 0)
//throw_exception(no_storage());
Modified: sandbox/monotonic/libs/monotonic/test/main.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/main.cpp (original)
+++ sandbox/monotonic/libs/monotonic/test/main.cpp 2009-06-17 05:54:23 EDT (Wed, 17 Jun 2009)
@@ -332,7 +332,10 @@
{
monotonic::storage<> store;
{
- typedef std::vector<std::list<int, monotonic::allocator<int> >, monotonic::allocator<std::list<int, monotonic::allocator<int> > > > Vector;
+ typedef std::list<int, monotonic::allocator<int> > List;
+ typedef std::vector<List, monotonic::allocator<List> > Vector;
+ BOOST_STATIC_ASSERT(monotonic::detail::IsMonotonic<List>::value);
+ BOOST_STATIC_ASSERT(monotonic::detail::IsMonotonic<Vector>::value);
Vector vec(store);
vec.resize(1);
BOOST_ASSERT(vec[0].get_allocator().get_storage() == vec.get_allocator().get_storage());
@@ -340,16 +343,19 @@
}
{
- typedef monotonic::map<int, monotonic::list<int> > Map;
+ typedef monotonic::list<int> List;
+ BOOST_STATIC_ASSERT(monotonic::detail::IsMonotonic<List>::value);
+ typedef monotonic::map<int, List > Map;
Map map(store);
map[42].push_back(123);
+ BOOST_ASSERT(map[42].get_allocator().get_storage() == map.get_allocator().get_storage());
}
{
typedef monotonic::map<int, monotonic::map<int, monotonic::list<int> > > Map;
Map map(store);
map[42][64].push_back(13);
-
+ BOOST_ASSERT(map[42][64].get_allocator().get_storage() == map.get_allocator().get_storage());
}
}
@@ -370,7 +376,7 @@
_set_se_translator(straight_to_debugger);
#endif
- //test_mono_map();
+ test_mono_map();
test_map_list_heap_stack();
//test_static_storage();
//run_all_tests();
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