Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54786 - in sandbox/monotonic: boost/monotonic boost/monotonic/containers boost/monotonic/detail boost/object_model boost/object_model/containers boost/object_model/detail boost/object_model/generic boost/object_model/type boost/utility libs/monotonic/doc libs/monotonic/doc/html libs/monotonic/doc/html/monotonic_storage libs/monotonic/doc/html/monotonic_storage/tutorial libs/monotonic/test libs/monotonic/test/Tests libs/monotonic/test/results libs/object_model/src/generic libs/object_model/test
From: christian.schladetsch_at_[hidden]
Date: 2009-07-07 19:06:32


Author: cschladetsch
Date: 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
New Revision: 54786
URL: http://svn.boost.org/trac/boost/changeset/54786

Log:
changed from tabs to spaces

Text files modified:
   sandbox/monotonic/boost/monotonic/allocator.hpp | 122 ++--
   sandbox/monotonic/boost/monotonic/allocator_base.hpp | 246 +++++-----
   sandbox/monotonic/boost/monotonic/config.hpp | 42
   sandbox/monotonic/boost/monotonic/containers/chain.hpp | 556 ++++++++++++------------
   sandbox/monotonic/boost/monotonic/containers/deque.hpp | 330 +++++++-------
   sandbox/monotonic/boost/monotonic/containers/inline_clone_allocator.hpp | 44
   sandbox/monotonic/boost/monotonic/containers/list.hpp | 312 ++++++------
   sandbox/monotonic/boost/monotonic/containers/map.hpp | 218 ++++----
   sandbox/monotonic/boost/monotonic/containers/ptr_list.hpp | 38
   sandbox/monotonic/boost/monotonic/containers/set.hpp | 182 ++++----
   sandbox/monotonic/boost/monotonic/containers/string.hpp | 242 +++++-----
   sandbox/monotonic/boost/monotonic/containers/vector.hpp | 326 +++++++-------
   sandbox/monotonic/boost/monotonic/detail/construct.hpp | 158 +++---
   sandbox/monotonic/boost/monotonic/detail/container.hpp | 64 +-
   sandbox/monotonic/boost/monotonic/detail/link.hpp | 142 +++--
   sandbox/monotonic/boost/monotonic/detail/pool.hpp | 98 ++--
   sandbox/monotonic/boost/monotonic/detail/postfix.hpp | 2
   sandbox/monotonic/boost/monotonic/detail/prefix.hpp | 8
   sandbox/monotonic/boost/monotonic/exceptions.hpp | 22
   sandbox/monotonic/boost/monotonic/fixed_storage.hpp | 375 ++++++++-------
   sandbox/monotonic/boost/monotonic/forward_declarations.hpp | 182 ++++---
   sandbox/monotonic/boost/monotonic/local.hpp | 160 +++---
   sandbox/monotonic/boost/monotonic/monotonic.hpp | 10
   sandbox/monotonic/boost/monotonic/reclaimable_storage.hpp | 388 ++++++++--------
   sandbox/monotonic/boost/monotonic/shared_allocator.hpp | 120 ++--
   sandbox/monotonic/boost/monotonic/shared_storage.hpp | 148 +++---
   sandbox/monotonic/boost/monotonic/stack.hpp | 613 +++++++++++++-------------
   sandbox/monotonic/boost/monotonic/static_storage.hpp | 194 ++++----
   sandbox/monotonic/boost/monotonic/storage.hpp | 545 +++++++++++++----------
   sandbox/monotonic/boost/monotonic/storage_base.hpp | 52 +-
   sandbox/monotonic/boost/monotonic/thread_local_storage.hpp | 128 ++--
   sandbox/monotonic/boost/object_model/builder.hpp | 66 +-
   sandbox/monotonic/boost/object_model/class.hpp | 68 +-
   sandbox/monotonic/boost/object_model/containers/vector.hpp | 184 ++++----
   sandbox/monotonic/boost/object_model/detail/allocator.hpp | 10
   sandbox/monotonic/boost/object_model/detail/base_type.hpp | 52 +-
   sandbox/monotonic/boost/object_model/detail/class_base.hpp | 98 ++--
   sandbox/monotonic/boost/object_model/detail/make_method.hpp | 160 +++---
   sandbox/monotonic/boost/object_model/detail/method_pointer.hpp | 544 ++++++++++++------------
   sandbox/monotonic/boost/object_model/dictionary.hpp | 50 +-
   sandbox/monotonic/boost/object_model/forward_declarations.hpp | 100 ++--
   sandbox/monotonic/boost/object_model/generic/base.hpp | 22
   sandbox/monotonic/boost/object_model/generic/class.hpp | 34
   sandbox/monotonic/boost/object_model/generic/method.hpp | 38
   sandbox/monotonic/boost/object_model/generic/object.hpp | 176 +++---
   sandbox/monotonic/boost/object_model/generic/registry.hpp | 16
   sandbox/monotonic/boost/object_model/generic/storage.hpp | 56 +-
   sandbox/monotonic/boost/object_model/handle.hpp | 22
   sandbox/monotonic/boost/object_model/label.hpp | 58 +-
   sandbox/monotonic/boost/object_model/method.hpp | 36
   sandbox/monotonic/boost/object_model/object.hpp | 160 +++---
   sandbox/monotonic/boost/object_model/registry.hpp | 742 ++++++++++++++++----------------
   sandbox/monotonic/boost/object_model/storage.hpp | 70 +-
   sandbox/monotonic/boost/object_model/string.hpp | 52 +-
   sandbox/monotonic/boost/object_model/string_stream.hpp | 16
   sandbox/monotonic/boost/object_model/system_traits.hpp | 26
   sandbox/monotonic/boost/object_model/type/modifiers.hpp | 46 +-
   sandbox/monotonic/boost/object_model/type/number.hpp | 76 +-
   sandbox/monotonic/boost/object_model/type/signature.hpp | 6
   sandbox/monotonic/boost/object_model/type/specifier.hpp | 84 +-
   sandbox/monotonic/boost/object_model/type/traits.hpp | 56 +-
   sandbox/monotonic/boost/utility/iter_range.hpp | 286 ++++++------
   sandbox/monotonic/libs/monotonic/doc/html/index.html | 4
   sandbox/monotonic/libs/monotonic/doc/html/monotonic_storage/change_log.html | 4
   sandbox/monotonic/libs/monotonic/doc/html/monotonic_storage/containers.html | 4
   sandbox/monotonic/libs/monotonic/doc/html/monotonic_storage/intro.html | 33 +
   sandbox/monotonic/libs/monotonic/doc/html/monotonic_storage/tutorial/stack.html | 106 +++
   sandbox/monotonic/libs/monotonic/doc/monotonic.qbk | 69 ++
   sandbox/monotonic/libs/monotonic/test/AllocatorTypes.h | 60 +-
   sandbox/monotonic/libs/monotonic/test/PoolResult.h | 176 +++---
   sandbox/monotonic/libs/monotonic/test/Tests.h | 320 +++++++-------
   sandbox/monotonic/libs/monotonic/test/Tests/tests.cpp | 906 ++++++++++++++++++++-------------------
   sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp | 828 ++++++++++++++++++------------------
   sandbox/monotonic/libs/monotonic/test/monotonic.sln | 3
   sandbox/monotonic/libs/monotonic/test/results/gcc.txt | 12
   sandbox/monotonic/libs/monotonic/test/results/msvc.txt | 12
   sandbox/monotonic/libs/object_model/src/generic/object.cpp | 186 ++++----
   sandbox/monotonic/libs/object_model/test/basic_tests.cpp | 378 ++++++++--------
   78 files changed, 6426 insertions(+), 6152 deletions(-)

Modified: sandbox/monotonic/boost/monotonic/allocator.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/allocator.hpp (original)
+++ sandbox/monotonic/boost/monotonic/allocator.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -11,67 +11,67 @@
 
 namespace boost
 {
- namespace monotonic
- {
- template <class Region, class Access>
- struct allocator<void, Region, Access>
- {
- typedef void* pointer;
- typedef const void* const_pointer;
-
- typedef void value_type;
- template <class U>
- struct rebind
- {
- typedef allocator<U, Region, Access> other;
- };
- };
-
- template <class T, class Region, class Access>
- struct allocator : allocator_base<T, allocator<T, Region, Access> >
- {
- typedef allocator_base<T, allocator<T, Region, Access> > Parent;
- using typename Parent::size_type;
- using typename Parent::difference_type;
- using typename Parent::pointer;
- using typename Parent::const_pointer;
- using typename Parent::reference;
- using typename Parent::const_reference;
- using typename Parent::value_type;
-
- template <class U>
- struct rebind
- {
- typedef allocator<U, Region, Access> other;
- };
-
- allocator() throw()
- : Parent(static_storage<Region,Access>::get_storage()) { }
-
- public:
- allocator(storage_base &store) throw()
- : Parent(store) { }
-
- public:
- allocator(const allocator& alloc) throw()
- : Parent(alloc) { }
-
- template <class U>
- allocator(const allocator<U, Region, Access> &alloc) throw()
- : Parent(alloc) { }
-
- friend bool operator==(allocator<T,Region, Access> const &A, allocator<T,Region, Access> const &B)
- {
- return static_cast<Parent const &>(A) == static_cast<Parent const &>(B);
- }
-
- friend bool operator!=(allocator<T,Region, Access> const &A, allocator<T,Region, Access> const &B)
- {
- return static_cast<Parent const &>(A) != static_cast<Parent const &>(B);
- }
- };
-
- } // namespace monotonic
+ namespace monotonic
+ {
+ template <class Region, class Access>
+ struct allocator<void, Region, Access>
+ {
+ typedef void* pointer;
+ typedef const void* const_pointer;
+
+ typedef void value_type;
+ template <class U>
+ struct rebind
+ {
+ typedef allocator<U, Region, Access> other;
+ };
+ };
+
+ template <class T, class Region, class Access>
+ struct allocator : allocator_base<T, allocator<T, Region, Access> >
+ {
+ typedef allocator_base<T, allocator<T, Region, Access> > Parent;
+ using typename Parent::size_type;
+ using typename Parent::difference_type;
+ using typename Parent::pointer;
+ using typename Parent::const_pointer;
+ using typename Parent::reference;
+ using typename Parent::const_reference;
+ using typename Parent::value_type;
+
+ template <class U>
+ struct rebind
+ {
+ typedef allocator<U, Region, Access> other;
+ };
+
+ allocator() throw()
+ : Parent(static_storage<Region,Access>::get_storage()) { }
+
+ public:
+ allocator(storage_base &store) throw()
+ : Parent(store) { }
+
+ public:
+ allocator(const allocator& alloc) throw()
+ : Parent(alloc) { }
+
+ template <class U>
+ allocator(const allocator<U, Region, Access> &alloc) throw()
+ : Parent(alloc) { }
+
+ friend bool operator==(allocator<T,Region, Access> const &A, allocator<T,Region, Access> const &B)
+ {
+ return static_cast<Parent const &>(A) == static_cast<Parent const &>(B);
+ }
+
+ friend bool operator!=(allocator<T,Region, Access> const &A, allocator<T,Region, Access> const &B)
+ {
+ return static_cast<Parent const &>(A) != static_cast<Parent const &>(B);
+ }
+ };
+
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/monotonic/allocator_base.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/allocator_base.hpp (original)
+++ sandbox/monotonic/boost/monotonic/allocator_base.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -21,139 +21,139 @@
 
 namespace boost
 {
- namespace monotonic
- {
- /// common to other monotonic allocators for type T of type Derived
- template <class T, class Derived>
- struct allocator_base
+ namespace monotonic
+ {
+ /// common to other monotonic allocators for type T of type Derived
+ template <class T, class Derived>
+ struct allocator_base
 #ifdef BOOST_HETEROGENOUS
- : cloneable::abstract_allocator
+ : cloneable::abstract_allocator
 #endif
- {
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- typedef T *pointer;
- typedef const T *const_pointer;
- typedef T &reference;
- typedef const T &const_reference;
- typedef T value_type;
- typedef detail::Construct<detail::is_monotonic<T>::value> Construct;
+ {
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef T *pointer;
+ typedef const T *const_pointer;
+ typedef T &reference;
+ typedef const T &const_reference;
+ typedef T value_type;
+ typedef detail::Construct<detail::is_monotonic<T>::value> Construct;
 
-// typedef mpl::integral_c<unsigned, 2> version;
- //typedef boost::interprocess::version_type<allocator_base, 2> version;
+// typedef mpl::integral_c<unsigned, 2> version;
+ //typedef boost::interprocess::version_type<allocator_base, 2> version;
 
- BOOST_STATIC_CONSTANT(size_t, alignment = boost::aligned_storage<sizeof(T)>::alignment);
+ BOOST_STATIC_CONSTANT(size_t, alignment = boost::aligned_storage<sizeof(T)>::alignment);
 
- //private:
- storage_base *storage;
+ //private:
+ storage_base *storage;
 
 #ifdef BOOST_HETEROGENOUS
- // override for abstract_allocator
- virtual cloneable::abstract_allocator::pointer allocate_bytes(size_t num_bytes, size_t alignment)
- {
- void *ptr = storage->allocate(num_bytes, alignment);
- return reinterpret_cast<cloneable::abstract_allocator::pointer>(ptr);
- }
-
- virtual void deallocate_bytes(char * /*bytes*/, size_t /*alignment*/ )
- {
- // do nothing
- }
+ // override for abstract_allocator
+ virtual cloneable::abstract_allocator::pointer allocate_bytes(size_t num_bytes, size_t alignment)
+ {
+ void *ptr = storage->allocate(num_bytes, alignment);
+ return reinterpret_cast<cloneable::abstract_allocator::pointer>(ptr);
+ }
+
+ virtual void deallocate_bytes(char * /*bytes*/, size_t /*alignment*/ )
+ {
+ // do nothing
+ }
 #endif
 
- public:
- allocator_base(storage_base &store) throw()
- : storage(&store) { }
-
- allocator_base(const allocator_base& alloc) throw()
- : storage(alloc.storage) { }
-
- template <class U, class D>
- allocator_base(const allocator_base<U,D> &alloc) throw()
- : storage(alloc.storage) { }
-
- pointer address(reference x) const
- {
- return &x;
- }
-
- const_pointer address(const_reference x) const
- {
- return &x;
- }
-
- pointer allocate(size_type num, const void * /*hint*/ = 0)
- {
- BOOST_ASSERT(num > 0);
- BOOST_ASSERT(storage != 0);
- return reinterpret_cast<T *>(storage->allocate(num*sizeof(T), alignment));
- }
-
- void deallocate(pointer ptr, size_type num)
- {
- storage->deallocate(ptr);//, num);
- }
-
- size_type max_size() const throw()
- {
- if (!storage)
- return 0;
- return storage->max_size()/sizeof(value_type);
- }
-
- void construct(pointer ptr)
- {
- Construct::Given(ptr, DerivedPtr());
- }
-
- void construct(pointer ptr, const T& val)
- {
- Construct::Given(ptr, val, DerivedPtr());
- }
-
- Derived *DerivedPtr()
- {
- return static_cast<Derived *>(this);
- }
-
- void destroy(pointer ptr)
- {
- if (!ptr)
- return;
- destroy(ptr, boost::has_trivial_destructor<value_type>());
- }
-
- void destroy(pointer ptr, const boost::false_type& )
- {
- (*ptr).~value_type();
- }
-
- void destroy(pointer, const boost::true_type& )
- {
- }
-
- void swap(allocator<value_type> &other)
- {
- std::swap(storage, other.storage);
- }
-
- storage_base *get_storage() const
- {
- return storage;
- }
-
- friend bool operator==(allocator_base<T,Derived> const &A, allocator_base<T,Derived> const &B)
- {
- return A.storage == B.storage;
- }
-
- friend bool operator!=(allocator_base<T,Derived> const &A, allocator_base<T,Derived> const &B)
- {
- return A.storage != B.storage;
- }
- };
+ public:
+ allocator_base(storage_base &store) throw()
+ : storage(&store) { }
+
+ allocator_base(const allocator_base& alloc) throw()
+ : storage(alloc.storage) { }
+
+ template <class U, class D>
+ allocator_base(const allocator_base<U,D> &alloc) throw()
+ : storage(alloc.storage) { }
+
+ pointer address(reference x) const
+ {
+ return &x;
+ }
+
+ const_pointer address(const_reference x) const
+ {
+ return &x;
+ }
+
+ pointer allocate(size_type num, const void * /*hint*/ = 0)
+ {
+ BOOST_ASSERT(num > 0);
+ BOOST_ASSERT(storage != 0);
+ return reinterpret_cast<T *>(storage->allocate(num*sizeof(T), alignment));
+ }
+
+ void deallocate(pointer ptr, size_type num)
+ {
+ storage->deallocate(ptr);//, num);
+ }
+
+ size_type max_size() const throw()
+ {
+ if (!storage)
+ return 0;
+ return storage->max_size()/sizeof(value_type);
+ }
+
+ void construct(pointer ptr)
+ {
+ Construct::Given(ptr, DerivedPtr());
+ }
+
+ void construct(pointer ptr, const T& val)
+ {
+ Construct::Given(ptr, val, DerivedPtr());
+ }
+
+ Derived *DerivedPtr()
+ {
+ return static_cast<Derived *>(this);
+ }
+
+ void destroy(pointer ptr)
+ {
+ if (!ptr)
+ return;
+ destroy(ptr, boost::has_trivial_destructor<value_type>());
+ }
+
+ void destroy(pointer ptr, const boost::false_type& )
+ {
+ (*ptr).~value_type();
+ }
+
+ void destroy(pointer, const boost::true_type& )
+ {
+ }
+
+ void swap(allocator<value_type> &other)
+ {
+ std::swap(storage, other.storage);
+ }
+
+ storage_base *get_storage() const
+ {
+ return storage;
+ }
+
+ friend bool operator==(allocator_base<T,Derived> const &A, allocator_base<T,Derived> const &B)
+ {
+ return A.storage == B.storage;
+ }
+
+ friend bool operator!=(allocator_base<T,Derived> const &A, allocator_base<T,Derived> const &B)
+ {
+ return A.storage != B.storage;
+ }
+ };
 
- } // namespace monotonic
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/monotonic/config.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/config.hpp (original)
+++ sandbox/monotonic/boost/monotonic/config.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -4,32 +4,32 @@
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
 #ifndef BOOST_MONOTONIC_CONFIG_HPP
-# define BOOST_MONOTONIC_CONFIG_HPP
+# define BOOST_MONOTONIC_CONFIG_HPP
 
-# include <boost/config.hpp>
-# include <memory>
+# include <boost/config.hpp>
+# include <memory>
 
 namespace boost
 {
- namespace monotonic
- {
- typedef std::allocator<char> default_allocator;
-
- struct DefaultSizes
- {
- enum
- {
- InlineSize = 32*1024, ///< buffer that is inline with the storage
- MinHeapIncrement = 32*1024*1024, ///< the smallest new chunk-size for heap storage
- //StaticInlineSize = 1*1024*1024, ///< inline size for a global store. this goes into your BSS
- //StaticMinHeapIncrement = 32*1024*1024,
- MinPoolSize = 8,
-
- RegionInlineSize = 8*1024,
- };
- };
+ namespace monotonic
+ {
+ typedef std::allocator<char> default_allocator;
+
+ struct DefaultSizes
+ {
+ enum
+ {
+ InlineSize = 32*1024, ///< buffer that is inline with the storage
+ MinHeapIncrement = 32*1024*1024, ///< the smallest new chunk-size for heap storage
+ //StaticInlineSize = 1*1024*1024, ///< inline size for a global store. this goes into your BSS
+ //StaticMinHeapIncrement = 32*1024*1024,
+ MinPoolSize = 8,
+
+ RegionInlineSize = 8*1024,
+ };
+ };
 
- } // namespace monotonic
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/monotonic/containers/chain.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/containers/chain.hpp (original)
+++ sandbox/monotonic/boost/monotonic/containers/chain.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -16,293 +16,293 @@
 
 namespace boost
 {
- namespace monotonic
- {
- /// a list of vectors that are tied together to present a contiguous sequence
- ///
- /// this is to provide a sequence type that is 'between' a list and a vector. it
- /// has slower access speed than a vector, but faster access speed than a list.
- ///
- /// unlike a vector, a chain cannot be resized
- ///
- /// this has limited utility outside of the context of a monotonic allocator.
- /// the reason to use it there is to avoid resizing a vector using a monotonic
- /// allocator, which is very wasteful. so, the trade-off is slightly slower
- /// access but ability to extend without resizing.
- ///
- template <class T, size_t ChunkSize = 64, class Region = default_region_tag, class Access = default_access_tag>
- struct chain
- {
- typedef chain<T, ChunkSize,Region,Access> Chain;
- typedef allocator<T,Region,Access> Allocator;
- typedef vector<T,Region,Access> Vector;
- typedef deque<Vector,Region,Access> Strands;
-
- typedef const_iter_range<Strands> ConstStrandsIterators;
- typedef iter_range<Strands> StrandsIterators;
- typedef const_iter_range<Vector> ConstVectorIterators;
- typedef iter_range<Vector> VectorIterators;
-
- typedef T value_type;
- typedef T &reference;
- typedef const T &const_reference;
-
- template <class R, class S, class V, class Derived>
- struct iterator_base : boost::iterator<random_access_traversal_tag, T>
- {
- typedef R Chain;
- typedef S StrandIterators;
- typedef V VectorIterators;
- Chain *parent;
- StrandIterators strand;
- VectorIterators vec;
-
- iterator_base() { }
- iterator_base(Chain &P)
- : parent(&P) { }
- iterator_base(Chain &P, StrandIterators const &S)
- : parent(&P), strand(S) { }
- iterator_base(Chain &P, StrandIterators const &S, VectorIterators const &V)
- : parent(&P), strand(S), vec(V) { }
- Derived &This()
- {
- return static_cast<Derived &>(*this);
- }
- Derived &operator++()
- {
- if (!++vec)
- {
- if (!++strand)
- {
- return This();
- }
- vec = *strand;
- }
- return This();
- }
- Derived operator++(int)
- {
- Derived tmp = This();
- ++*this;
- return tmp;
- }
- bool operator==(iterator_base const &B) const
- {
- return parent == B.parent && strand == B.strand && vec == B.vec;
- }
- bool operator!=(iterator_base const &B) const
- {
- return !(*this == B);
- }
- };
- struct iterator : iterator_base<Chain, StrandsIterators, VectorIterators, iterator>
- {
- typedef iterator_base<Chain, StrandsIterators, VectorIterators, iterator> Parent;
- iterator() { }
- iterator(Chain &P)
- : Parent(P) { }
- iterator(Chain &P, StrandsIterators const &S)
- : Parent(P, S) { }
- iterator(Chain &P, StrandsIterators const &S, VectorIterators const &V)
- : Parent(P, S, V) { }
- T const &operator*() const
- {
- return *Parent::vec;
- }
- T &operator*()
- {
- return *Parent::vec;
- }
- };
- typedef iterator Iter;
- struct const_iterator : iterator_base<Chain const, ConstStrandsIterators, ConstVectorIterators, const_iterator>
- {
- typedef iterator_base<Chain const, ConstStrandsIterators, ConstVectorIterators, const_iterator> Parent;
- const_iterator() { }
- const_iterator(Chain const &P)
- : Parent(P) { }
- const_iterator(Iter const &X)
- : Parent(*X.parent, X.strand, X.vec)
- { }
- const_iterator(Chain const &P, ConstStrandsIterators const &S)
- : Parent(P, S) { }
- const_iterator(Chain const &P, ConstStrandsIterators const &S, ConstVectorIterators const &V)
- : Parent(P, S, V) { }
- T const &operator*() const
- {
- return *Parent::vec;
- }
- };
-
- private:
- Allocator alloc;
- Strands strands;
-
- public:
- chain() { }
- chain(Allocator A)
- : alloc(A), strands(A) { }
- chain(size_t len, Allocator A = Allocator())
- : alloc(A), strands(A)
- {
- // TODO
- }
- chain(size_t len, T const &X, Allocator A = Allocator())
- : alloc(A), strands(A)
- {
- strands.push_back(Vector(alloc));
- strands.back().resize(len, X);
- }
- template <class II>
- chain(II F, II L, Allocator A = Allocator())
- : alloc(A), strands(A)
- {
- strands.push_back(Vector(alloc));
- Vector &vec = strands.back();
- size_t len = std::distance(F,L);
- vec.resize(len);
- typename Vector::iterator G = vec.begin();
- for (size_t N = 0; N < len; ++F, ++G)
- *G = *F;
- }
-
- size_t size() const
- {
- size_t len = 0;
- BOOST_FOREACH(Vector const &vec, strands)
- {
- len += vec.size();
- }
- return len;
- }
- void clear()
- {
- strands.clear();
- }
- bool empty() const
- {
- return strands.empty() || size() == 0;
- }
- const_iterator begin() const
- {
- if (strands.empty())
- return const_iterator(*this);
- return const_iterator(*this, strands, strands.front());
- }
- const_iterator end() const
- {
- if (strands.empty())
- return const_iterator(*this);
- return const_iterator(*this, strands.end(), strands.back().end());
- }
- iterator begin()
- {
- if (strands.empty())
- return iterator(*this);
- return iterator(*this, strands, strands.front());
- }
- iterator end()
- {
- if (strands.empty())
- return iterator(*this);
- return iterator(*this, strands.end(), strands.back().end());
- }
- void push_back(T const &X)
- {
- bool require_new_vec = strands.empty();
- require_new_vec = require_new_vec || strands.back().size() == strands.back().capacity();
- if (require_new_vec)
- {
- strands.push_back(Vector(alloc));
- strands.back().reserve(ChunkSize);
- }
- strands.back().push_back(X);
- }
-
- T &at(size_t index)
- {
- size_t offset = 0;
- BOOST_FOREACH(Vector &vec, strands)
- {
- size_t local = index - offset;
- if (local < vec.size())
- {
- return vec.at(local);
- }
- offset += vec.size();
- if (offset > index)
- break;
- }
- throw std::out_of_range("chain");
- }
- T const &at(size_t index) const
- {
- size_t offset = 0;
- BOOST_FOREACH(Vector const &vec, strands)
- {
- size_t local = index - offset;
- if (local < vec.size())
- {
- return vec.at(local);
- }
- offset += vec.size();
- if (offset < index)
- break;
- }
- throw std::out_of_range("chain");
- }
- T &operator[](size_t index)
- {
- return at(index);
- }
- T const &operator[](size_t index) const
- {
- return at(index);
- }
- };
+ namespace monotonic
+ {
+ /// a list of vectors that are tied together to present a contiguous sequence
+ ///
+ /// this is to provide a sequence type that is 'between' a list and a vector. it
+ /// has slower access speed than a vector, but faster access speed than a list.
+ ///
+ /// unlike a vector, a chain cannot be resized
+ ///
+ /// this has limited utility outside of the context of a monotonic allocator.
+ /// the reason to use it there is to avoid resizing a vector using a monotonic
+ /// allocator, which is very wasteful. so, the trade-off is slightly slower
+ /// access but ability to extend without resizing.
+ ///
+ template <class T, size_t ChunkSize = 64, class Region = default_region_tag, class Access = default_access_tag>
+ struct chain
+ {
+ typedef chain<T, ChunkSize,Region,Access> Chain;
+ typedef allocator<T,Region,Access> Allocator;
+ typedef vector<T,Region,Access> Vector;
+ typedef deque<Vector,Region,Access> Strands;
+
+ typedef const_iter_range<Strands> ConstStrandsIterators;
+ typedef iter_range<Strands> StrandsIterators;
+ typedef const_iter_range<Vector> ConstVectorIterators;
+ typedef iter_range<Vector> VectorIterators;
+
+ typedef T value_type;
+ typedef T &reference;
+ typedef const T &const_reference;
+
+ template <class R, class S, class V, class Derived>
+ struct iterator_base : boost::iterator<random_access_traversal_tag, T>
+ {
+ typedef R Chain;
+ typedef S StrandIterators;
+ typedef V VectorIterators;
+ Chain *parent;
+ StrandIterators strand;
+ VectorIterators vec;
+
+ iterator_base() { }
+ iterator_base(Chain &P)
+ : parent(&P) { }
+ iterator_base(Chain &P, StrandIterators const &S)
+ : parent(&P), strand(S) { }
+ iterator_base(Chain &P, StrandIterators const &S, VectorIterators const &V)
+ : parent(&P), strand(S), vec(V) { }
+ Derived &This()
+ {
+ return static_cast<Derived &>(*this);
+ }
+ Derived &operator++()
+ {
+ if (!++vec)
+ {
+ if (!++strand)
+ {
+ return This();
+ }
+ vec = *strand;
+ }
+ return This();
+ }
+ Derived operator++(int)
+ {
+ Derived tmp = This();
+ ++*this;
+ return tmp;
+ }
+ bool operator==(iterator_base const &B) const
+ {
+ return parent == B.parent && strand == B.strand && vec == B.vec;
+ }
+ bool operator!=(iterator_base const &B) const
+ {
+ return !(*this == B);
+ }
+ };
+ struct iterator : iterator_base<Chain, StrandsIterators, VectorIterators, iterator>
+ {
+ typedef iterator_base<Chain, StrandsIterators, VectorIterators, iterator> Parent;
+ iterator() { }
+ iterator(Chain &P)
+ : Parent(P) { }
+ iterator(Chain &P, StrandsIterators const &S)
+ : Parent(P, S) { }
+ iterator(Chain &P, StrandsIterators const &S, VectorIterators const &V)
+ : Parent(P, S, V) { }
+ T const &operator*() const
+ {
+ return *Parent::vec;
+ }
+ T &operator*()
+ {
+ return *Parent::vec;
+ }
+ };
+ typedef iterator Iter;
+ struct const_iterator : iterator_base<Chain const, ConstStrandsIterators, ConstVectorIterators, const_iterator>
+ {
+ typedef iterator_base<Chain const, ConstStrandsIterators, ConstVectorIterators, const_iterator> Parent;
+ const_iterator() { }
+ const_iterator(Chain const &P)
+ : Parent(P) { }
+ const_iterator(Iter const &X)
+ : Parent(*X.parent, X.strand, X.vec)
+ { }
+ const_iterator(Chain const &P, ConstStrandsIterators const &S)
+ : Parent(P, S) { }
+ const_iterator(Chain const &P, ConstStrandsIterators const &S, ConstVectorIterators const &V)
+ : Parent(P, S, V) { }
+ T const &operator*() const
+ {
+ return *Parent::vec;
+ }
+ };
+
+ private:
+ Allocator alloc;
+ Strands strands;
+
+ public:
+ chain() { }
+ chain(Allocator A)
+ : alloc(A), strands(A) { }
+ chain(size_t len, Allocator A = Allocator())
+ : alloc(A), strands(A)
+ {
+ // TODO
+ }
+ chain(size_t len, T const &X, Allocator A = Allocator())
+ : alloc(A), strands(A)
+ {
+ strands.push_back(Vector(alloc));
+ strands.back().resize(len, X);
+ }
+ template <class II>
+ chain(II F, II L, Allocator A = Allocator())
+ : alloc(A), strands(A)
+ {
+ strands.push_back(Vector(alloc));
+ Vector &vec = strands.back();
+ size_t len = std::distance(F,L);
+ vec.resize(len);
+ typename Vector::iterator G = vec.begin();
+ for (size_t N = 0; N < len; ++F, ++G)
+ *G = *F;
+ }
+
+ size_t size() const
+ {
+ size_t len = 0;
+ BOOST_FOREACH(Vector const &vec, strands)
+ {
+ len += vec.size();
+ }
+ return len;
+ }
+ void clear()
+ {
+ strands.clear();
+ }
+ bool empty() const
+ {
+ return strands.empty() || size() == 0;
+ }
+ const_iterator begin() const
+ {
+ if (strands.empty())
+ return const_iterator(*this);
+ return const_iterator(*this, strands, strands.front());
+ }
+ const_iterator end() const
+ {
+ if (strands.empty())
+ return const_iterator(*this);
+ return const_iterator(*this, strands.end(), strands.back().end());
+ }
+ iterator begin()
+ {
+ if (strands.empty())
+ return iterator(*this);
+ return iterator(*this, strands, strands.front());
+ }
+ iterator end()
+ {
+ if (strands.empty())
+ return iterator(*this);
+ return iterator(*this, strands.end(), strands.back().end());
+ }
+ void push_back(T const &X)
+ {
+ bool require_new_vec = strands.empty();
+ require_new_vec = require_new_vec || strands.back().size() == strands.back().capacity();
+ if (require_new_vec)
+ {
+ strands.push_back(Vector(alloc));
+ strands.back().reserve(ChunkSize);
+ }
+ strands.back().push_back(X);
+ }
+
+ T &at(size_t index)
+ {
+ size_t offset = 0;
+ BOOST_FOREACH(Vector &vec, strands)
+ {
+ size_t local = index - offset;
+ if (local < vec.size())
+ {
+ return vec.at(local);
+ }
+ offset += vec.size();
+ if (offset > index)
+ break;
+ }
+ throw std::out_of_range("chain");
+ }
+ T const &at(size_t index) const
+ {
+ size_t offset = 0;
+ BOOST_FOREACH(Vector const &vec, strands)
+ {
+ size_t local = index - offset;
+ if (local < vec.size())
+ {
+ return vec.at(local);
+ }
+ offset += vec.size();
+ if (offset < index)
+ break;
+ }
+ throw std::out_of_range("chain");
+ }
+ T &operator[](size_t index)
+ {
+ return at(index);
+ }
+ T const &operator[](size_t index) const
+ {
+ return at(index);
+ }
+ };
 
 #ifdef WIN32
 // warning C4996: 'std::equal': Function call with parameters that may be unsafe
-# pragma warning(push)
-# pragma warning(disable:4996)
+# pragma warning(push)
+# pragma warning(disable:4996)
 #endif
 
- template <class Ty,size_t N,class R,class Acc,class Ty2,size_t N2,class R2,class Acc2>
- bool operator==(chain<Ty,N,R,Acc> const &A, chain<Ty2,N2,R2,Acc2> const &B)
- {
- return A.size() == B.size() && std::equal(A.begin(), A.end(), B.begin());
- }
+ template <class Ty,size_t N,class R,class Acc,class Ty2,size_t N2,class R2,class Acc2>
+ bool operator==(chain<Ty,N,R,Acc> const &A, chain<Ty2,N2,R2,Acc2> const &B)
+ {
+ return A.size() == B.size() && std::equal(A.begin(), A.end(), B.begin());
+ }
 #ifdef WIN32
-# pragma warning(pop)
+# pragma warning(pop)
 #endif
 
- template <class Ty,size_t N,class R,class Acc,class Ty2,size_t N2,class R2,class Acc2>
- bool operator!=(chain<Ty,N,R,Acc> const &A, chain<Ty2,N2,R2,Acc2> const &B)
- {
- return !(A == B);
- }
- template <class Ty,size_t N,class R,class Acc,class Ty2,size_t N2,class R2,class Acc2>
- bool operator<(chain<Ty,N,R,Acc> const &A, chain<Ty2,N2,R2,Acc2> const &B)
- {
- return std::lexicographical_compare(A.begin(), A.end(), B.begin(), B.end());
- }
- template <class Ty,size_t N,class R,class Acc,class Ty2,size_t N2,class R2,class Acc2>
- bool operator>(chain<Ty,N,R,Acc> const &A, chain<Ty2,N2,R2,Acc2> const &B)
- {
- return std::lexicographical_compare(B.begin(), B.end(), A.begin(), A.end());
- }
- template <class Ty,size_t N,class R,class Acc,class Ty2,size_t N2,class R2,class Acc2>
- bool operator<=(chain<Ty,N,R,Acc> const &A, chain<Ty2,N2,R2,Acc2> const &B)
- {
- return !(A > B);
- }
- template <class Ty,size_t N,class R,class Acc,class Ty2,size_t N2,class R2,class Acc2>
- bool operator>=(chain<Ty,N,R,Acc> const &A, chain<Ty2,N2,R2,Acc2> const &B)
- {
- return !(A < B);
- }
+ template <class Ty,size_t N,class R,class Acc,class Ty2,size_t N2,class R2,class Acc2>
+ bool operator!=(chain<Ty,N,R,Acc> const &A, chain<Ty2,N2,R2,Acc2> const &B)
+ {
+ return !(A == B);
+ }
+ template <class Ty,size_t N,class R,class Acc,class Ty2,size_t N2,class R2,class Acc2>
+ bool operator<(chain<Ty,N,R,Acc> const &A, chain<Ty2,N2,R2,Acc2> const &B)
+ {
+ return std::lexicographical_compare(A.begin(), A.end(), B.begin(), B.end());
+ }
+ template <class Ty,size_t N,class R,class Acc,class Ty2,size_t N2,class R2,class Acc2>
+ bool operator>(chain<Ty,N,R,Acc> const &A, chain<Ty2,N2,R2,Acc2> const &B)
+ {
+ return std::lexicographical_compare(B.begin(), B.end(), A.begin(), A.end());
+ }
+ template <class Ty,size_t N,class R,class Acc,class Ty2,size_t N2,class R2,class Acc2>
+ bool operator<=(chain<Ty,N,R,Acc> const &A, chain<Ty2,N2,R2,Acc2> const &B)
+ {
+ return !(A > B);
+ }
+ template <class Ty,size_t N,class R,class Acc,class Ty2,size_t N2,class R2,class Acc2>
+ bool operator>=(chain<Ty,N,R,Acc> const &A, chain<Ty2,N2,R2,Acc2> const &B)
+ {
+ return !(A < B);
+ }
 
- } // namespace monotonic
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/monotonic/containers/deque.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/containers/deque.hpp (original)
+++ sandbox/monotonic/boost/monotonic/containers/deque.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -12,172 +12,172 @@
 
 namespace boost
 {
- namespace monotonic
- {
- /// a vector that uses a monotonic allocator in the given region, with given access system
- template <class T, class Region = default_region_tag, class Access = default_access_tag>
- struct deque : detail::container<deque<T,Region,Access> >
- {
- typedef allocator<T,Region,Access> Allocator;
- typedef detail::container<std::vector<T, Allocator > > Parent;
- typedef detail::Create<detail::is_monotonic<T>::value, T> Create;
- typedef interprocess::deque<T,Allocator> Impl;
-
- typedef typename Impl::iterator iterator;
- typedef typename Impl::const_iterator const_iterator;
- typedef typename Impl::size_type size_type;
- typedef typename Impl::value_type value_type;
- typedef typename Impl::reference reference;
- typedef typename Impl::const_reference const_reference;
-
- private:
- Impl impl;
-
- public:
- deque() { }
- deque(Allocator A)
- : impl(A) { }
- deque(size_t N, T const &X, Allocator A = Allocator())
- : impl(N,X,A) { }
- template <class II>
- deque(II F, II L, Allocator A = Allocator())
- : impl(F,L,A) { }
-
- Allocator get_allocator() const
- {
- return impl.get_allocator();
- }
- Impl const &get_impl() const
- {
- return impl;
- }
- Impl &get_impl()
- {
- return impl;
- }
- bool empty() const
- {
- return impl.empty();
- }
- size_type size() const
- {
- return impl.size();
- }
- void resize(size_type size)
- {
- impl.resize(size);//, Creator::Create(GetStorage()));
- }
- void reserve(size_type size)
- {
- impl.reserve(size);
- }
- size_type capacity() const
- {
- return impl.capacity();
- }
- reference at(size_type index)
- {
- return impl.at(index);
- }
- const_reference at(size_type index) const
- {
- return impl.at(index);
- }
- reference operator[](size_type index)
- {
- return impl[index];
- }
- const_reference operator[](size_type index) const
- {
- return impl[index];
- }
- void push_back(value_type const &value)
- {
- impl.push_back(value);
- }
- void pop_back()
- {
- impl.pop_back();
- }
- void push_front(value_type const &value)
- {
- impl.push_front(value);
- }
- void pop_front()
- {
- impl.pop_front();
- }
- iterator begin()
- {
- return impl.begin();
- }
- iterator end()
- {
- return impl.end();
- }
- const_iterator begin() const
- {
- return impl.begin();
- }
- const_iterator end() const
- {
- return impl.end();
- }
- value_type const &front() const
- {
- return impl.front();
- }
- value_type &front()
- {
- return impl.front();
- }
- value_type const &back() const
- {
- return impl.back();
- }
- value_type &back()
- {
- return impl.back();
- }
-
- void swap(deque &other)
- {
- impl.swap(other.impl);
- }
- };
-
- template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
- bool operator==(deque<Ty,R,Acc> const &A, deque<Ty2,R2,Acc2> const &B)
- {
- return A.size() == B.size() && std::equal(A.begin(), A.end(), B.begin());
- }
- template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
- bool operator!=(deque<Ty,R,Acc> const &A, deque<Ty2,R2,Acc2> const &B)
- {
- return !(A == B);
- }
- template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
- bool operator<(deque<Ty,R,Acc> const &A, deque<Ty2,R2,Acc2> const &B)
- {
- return std::lexicographical_compare(A.begin(), A.end(), B.begin(), B.end());
- }
- template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
- bool operator>(deque<Ty,R,Acc> const &A, deque<Ty2,R2,Acc2> const &B)
- {
- return std::lexicographical_compare(B.begin(), B.end(), A.begin(), A.end());
- }
- template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
- bool operator<=(deque<Ty,R,Acc> const &A, deque<Ty2,R2,Acc2> const &B)
- {
- return !(A > B);
- }
- template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
- bool operator>=(deque<Ty,R,Acc> const &A, deque<Ty2,R2,Acc2> const &B)
- {
- return !(A < B);
- }
+ namespace monotonic
+ {
+ /// a vector that uses a monotonic allocator in the given region, with given access system
+ template <class T, class Region = default_region_tag, class Access = default_access_tag>
+ struct deque : detail::container<deque<T,Region,Access> >
+ {
+ typedef allocator<T,Region,Access> Allocator;
+ typedef detail::container<std::vector<T, Allocator > > Parent;
+ typedef detail::Create<detail::is_monotonic<T>::value, T> Create;
+ typedef interprocess::deque<T,Allocator> Impl;
+
+ typedef typename Impl::iterator iterator;
+ typedef typename Impl::const_iterator const_iterator;
+ typedef typename Impl::size_type size_type;
+ typedef typename Impl::value_type value_type;
+ typedef typename Impl::reference reference;
+ typedef typename Impl::const_reference const_reference;
+
+ private:
+ Impl impl;
+
+ public:
+ deque() { }
+ deque(Allocator A)
+ : impl(A) { }
+ deque(size_t N, T const &X, Allocator A = Allocator())
+ : impl(N,X,A) { }
+ template <class II>
+ deque(II F, II L, Allocator A = Allocator())
+ : impl(F,L,A) { }
+
+ Allocator get_allocator() const
+ {
+ return impl.get_allocator();
+ }
+ Impl const &get_impl() const
+ {
+ return impl;
+ }
+ Impl &get_impl()
+ {
+ return impl;
+ }
+ bool empty() const
+ {
+ return impl.empty();
+ }
+ size_type size() const
+ {
+ return impl.size();
+ }
+ void resize(size_type size)
+ {
+ impl.resize(size);//, Creator::Create(GetStorage()));
+ }
+ void reserve(size_type size)
+ {
+ impl.reserve(size);
+ }
+ size_type capacity() const
+ {
+ return impl.capacity();
+ }
+ reference at(size_type index)
+ {
+ return impl.at(index);
+ }
+ const_reference at(size_type index) const
+ {
+ return impl.at(index);
+ }
+ reference operator[](size_type index)
+ {
+ return impl[index];
+ }
+ const_reference operator[](size_type index) const
+ {
+ return impl[index];
+ }
+ void push_back(value_type const &value)
+ {
+ impl.push_back(value);
+ }
+ void pop_back()
+ {
+ impl.pop_back();
+ }
+ void push_front(value_type const &value)
+ {
+ impl.push_front(value);
+ }
+ void pop_front()
+ {
+ impl.pop_front();
+ }
+ iterator begin()
+ {
+ return impl.begin();
+ }
+ iterator end()
+ {
+ return impl.end();
+ }
+ const_iterator begin() const
+ {
+ return impl.begin();
+ }
+ const_iterator end() const
+ {
+ return impl.end();
+ }
+ value_type const &front() const
+ {
+ return impl.front();
+ }
+ value_type &front()
+ {
+ return impl.front();
+ }
+ value_type const &back() const
+ {
+ return impl.back();
+ }
+ value_type &back()
+ {
+ return impl.back();
+ }
+
+ void swap(deque &other)
+ {
+ impl.swap(other.impl);
+ }
+ };
+
+ template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
+ bool operator==(deque<Ty,R,Acc> const &A, deque<Ty2,R2,Acc2> const &B)
+ {
+ return A.size() == B.size() && std::equal(A.begin(), A.end(), B.begin());
+ }
+ template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
+ bool operator!=(deque<Ty,R,Acc> const &A, deque<Ty2,R2,Acc2> const &B)
+ {
+ return !(A == B);
+ }
+ template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
+ bool operator<(deque<Ty,R,Acc> const &A, deque<Ty2,R2,Acc2> const &B)
+ {
+ return std::lexicographical_compare(A.begin(), A.end(), B.begin(), B.end());
+ }
+ template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
+ bool operator>(deque<Ty,R,Acc> const &A, deque<Ty2,R2,Acc2> const &B)
+ {
+ return std::lexicographical_compare(B.begin(), B.end(), A.begin(), A.end());
+ }
+ template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
+ bool operator<=(deque<Ty,R,Acc> const &A, deque<Ty2,R2,Acc2> const &B)
+ {
+ return !(A > B);
+ }
+ template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
+ bool operator>=(deque<Ty,R,Acc> const &A, deque<Ty2,R2,Acc2> const &B)
+ {
+ return !(A < B);
+ }
 
- } // namespace monotonic
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/monotonic/containers/inline_clone_allocator.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/containers/inline_clone_allocator.hpp (original)
+++ sandbox/monotonic/boost/monotonic/containers/inline_clone_allocator.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -11,29 +11,29 @@
 
 namespace boost
 {
- namespace monotonic
- {
- /// custom clone allocator for ptr-containers using a monotonic allocator.
- /// see http://www.boost.org/doc/libs/1_38_0/libs/ptr_container/doc/reference.html for details.
- struct inline_clone_allocator
- {
- template< class U >
- static U* allocate_clone( const U& r )
- {
- // can't allocate clone without access to the monotonic allocator.
- // this is a design fault in boost::ptr_container.
- return 0;
- }
-
- template< class U >
- static void deallocate_clone( const U* clone )
- {
- if (clone)
- clone->U::~U();
- }
- };
+ namespace monotonic
+ {
+ /// custom clone allocator for ptr-containers using a monotonic allocator.
+ /// see http://www.boost.org/doc/libs/1_38_0/libs/ptr_container/doc/reference.html for details.
+ struct inline_clone_allocator
+ {
+ template< class U >
+ static U* allocate_clone( const U& r )
+ {
+ // can't allocate clone without access to the monotonic allocator.
+ // this is a design fault in boost::ptr_container.
+ return 0;
+ }
+
+ template< class U >
+ static void deallocate_clone( const U* clone )
+ {
+ if (clone)
+ clone->U::~U();
+ }
+ };
 
- } // namespace monotonic
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/monotonic/containers/list.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/containers/list.hpp (original)
+++ sandbox/monotonic/boost/monotonic/containers/list.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -34,163 +34,163 @@
 
 namespace boost
 {
- namespace monotonic
- {
- /// A list that uses a monotonic allocator with the given region and access
- template <class T, class Region = default_region_tag, class Access = default_access_tag>
- struct list : detail::container<list<T,Region,Access> >
- {
- typedef allocator<T,Region,Access> Allocator;
- //typedef interprocess::list<T, Allocator> List, Implementation;
- typedef std::list<T, Allocator> List, Implementation;
- typedef detail::container<list<T, Allocator> > Parent;
-
- typedef typename List::iterator iterator;
- typedef typename List::const_iterator const_iterator;
- typedef typename List::size_type size_type;
- typedef typename List::value_type value_type;
- typedef typename List::reference reference;
- typedef typename List::const_reference const_reference;
- typedef list<T,Region,Access> This;
-
- private:
- Implementation impl;
-
- public:
- list() { }
- list(Allocator A)
- : impl(A) { }
-
- template <class II>
- list(II F, II L, Allocator A = Allocator())
- : impl(F,L,A) { }
-
- Allocator get_allocator()
- {
- return impl.get_allocator();
- }
- bool empty() const
- {
- return impl.empty();
- }
- size_type size() const
- {
- return impl.size();
- }
- void push_back(value_type const &value)
- {
- impl.push_back(value);
- }
- void pop_back()
- {
- impl.pop_back();
- }
- void push_front(value_type const &value)
- {
- impl.push_front(value);
- }
- void pop_front()
- {
- impl.pop_front();
- }
- iterator begin()
- {
- return impl.begin();
- }
- iterator end()
- {
- return impl.end();
- }
- const_iterator begin() const
- {
- return impl.begin();
- }
- const_iterator end() const
- {
- return impl.end();
- }
- value_type const &front() const
- {
- return impl.front();
- }
- value_type &front()
- {
- return impl.front();
- }
- value_type const &back() const
- {
- return impl.back();
- }
- value_type &back()
- {
- return impl.back();
- }
-
- void erase(iterator A)
- {
- impl.erase(A);
- }
-
- template <class Pred2>
- void sort(Pred2 pred)
- {
- impl.sort(pred);
- }
-
- void sort()
- {
- sort(std::less<T>());
- }
-
- template <class Pred3>
- void merge(This& other, Pred3 pred)
- {
- impl.merge(other.impl, pred);
- }
-
- void splice(const_iterator where, This& other)
- {
- impl.splice(where, other.impl);
- }
-
- void swap(This &other)
- {
- impl.swap(other.impl);
- }
- };
-
- template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
- bool operator==(list<Ty,R,Acc> const &A, list<Ty2,R2,Acc2> const &B)
- {
- return A.size() == B.size() && std::equal(A.begin(), A.end(), B.begin());
- }
- template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
- bool operator!=(list<Ty,R,Acc> const &A, list<Ty2,R2,Acc2> const &B)
- {
- return !(A == B);
- }
- template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
- bool operator<(list<Ty,R,Acc> const &A, list<Ty2,R2,Acc2> const &B)
- {
- return std::lexicographical_compare(A.begin(), A.end(), B.begin(), B.end());
- }
- template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
- bool operator>(list<Ty,R,Acc> const &A, list<Ty2,R2,Acc2> const &B)
- {
- return std::lexicographical_compare(B.begin(), B.end(), A.begin(), A.end());
- }
- template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
- bool operator<=(list<Ty,R,Acc> const &A, list<Ty2,R2,Acc2> const &B)
- {
- return !(A > B);
- }
- template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
- bool operator>=(list<Ty,R,Acc> const &A, list<Ty2,R2,Acc2> const &B)
- {
- return !(A < B);
- }
+ namespace monotonic
+ {
+ /// A list that uses a monotonic allocator with the given region and access
+ template <class T, class Region = default_region_tag, class Access = default_access_tag>
+ struct list : detail::container<list<T,Region,Access> >
+ {
+ typedef allocator<T,Region,Access> Allocator;
+ //typedef interprocess::list<T, Allocator> List, Implementation;
+ typedef std::list<T, Allocator> List, Implementation;
+ typedef detail::container<list<T, Allocator> > Parent;
+
+ typedef typename List::iterator iterator;
+ typedef typename List::const_iterator const_iterator;
+ typedef typename List::size_type size_type;
+ typedef typename List::value_type value_type;
+ typedef typename List::reference reference;
+ typedef typename List::const_reference const_reference;
+ typedef list<T,Region,Access> This;
+
+ private:
+ Implementation impl;
+
+ public:
+ list() { }
+ list(Allocator A)
+ : impl(A) { }
+
+ template <class II>
+ list(II F, II L, Allocator A = Allocator())
+ : impl(F,L,A) { }
+
+ Allocator get_allocator()
+ {
+ return impl.get_allocator();
+ }
+ bool empty() const
+ {
+ return impl.empty();
+ }
+ size_type size() const
+ {
+ return impl.size();
+ }
+ void push_back(value_type const &value)
+ {
+ impl.push_back(value);
+ }
+ void pop_back()
+ {
+ impl.pop_back();
+ }
+ void push_front(value_type const &value)
+ {
+ impl.push_front(value);
+ }
+ void pop_front()
+ {
+ impl.pop_front();
+ }
+ iterator begin()
+ {
+ return impl.begin();
+ }
+ iterator end()
+ {
+ return impl.end();
+ }
+ const_iterator begin() const
+ {
+ return impl.begin();
+ }
+ const_iterator end() const
+ {
+ return impl.end();
+ }
+ value_type const &front() const
+ {
+ return impl.front();
+ }
+ value_type &front()
+ {
+ return impl.front();
+ }
+ value_type const &back() const
+ {
+ return impl.back();
+ }
+ value_type &back()
+ {
+ return impl.back();
+ }
+
+ void erase(iterator A)
+ {
+ impl.erase(A);
+ }
+
+ template <class Pred2>
+ void sort(Pred2 pred)
+ {
+ impl.sort(pred);
+ }
+
+ void sort()
+ {
+ sort(std::less<T>());
+ }
+
+ template <class Pred3>
+ void merge(This& other, Pred3 pred)
+ {
+ impl.merge(other.impl, pred);
+ }
+
+ void splice(const_iterator where, This& other)
+ {
+ impl.splice(where, other.impl);
+ }
+
+ void swap(This &other)
+ {
+ impl.swap(other.impl);
+ }
+ };
+
+ template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
+ bool operator==(list<Ty,R,Acc> const &A, list<Ty2,R2,Acc2> const &B)
+ {
+ return A.size() == B.size() && std::equal(A.begin(), A.end(), B.begin());
+ }
+ template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
+ bool operator!=(list<Ty,R,Acc> const &A, list<Ty2,R2,Acc2> const &B)
+ {
+ return !(A == B);
+ }
+ template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
+ bool operator<(list<Ty,R,Acc> const &A, list<Ty2,R2,Acc2> const &B)
+ {
+ return std::lexicographical_compare(A.begin(), A.end(), B.begin(), B.end());
+ }
+ template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
+ bool operator>(list<Ty,R,Acc> const &A, list<Ty2,R2,Acc2> const &B)
+ {
+ return std::lexicographical_compare(B.begin(), B.end(), A.begin(), A.end());
+ }
+ template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
+ bool operator<=(list<Ty,R,Acc> const &A, list<Ty2,R2,Acc2> const &B)
+ {
+ return !(A > B);
+ }
+ template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
+ bool operator>=(list<Ty,R,Acc> const &A, list<Ty2,R2,Acc2> const &B)
+ {
+ return !(A < B);
+ }
 
- } // namespace monotonic
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/monotonic/containers/map.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/containers/map.hpp (original)
+++ sandbox/monotonic/boost/monotonic/containers/map.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -13,116 +13,116 @@
 
 namespace boost
 {
- namespace monotonic
- {
- /// A map that uses a monotonic allocator
- template <class K // key-type
- , class T // value-type
- , class Region = default_region_tag // allocation region
- , class P = std::less<K> // predicate
- , class Access = default_access_tag // access type
- >
- struct map : detail::container<map<K,T,Region,P,Access> >
- {
- typedef P Predicate;
- typedef allocator<K,Region,Access> Allocator;
- typedef detail::container<map<K,T,Region,P,Access> > Parent;
- typedef detail::Create<detail::is_monotonic<T>::value, T> Create;
-
- typedef std::map<K,T,P,Allocator > Map, Implementation;
- typedef typename Map::iterator iterator;
- typedef typename Map::const_iterator const_iterator;
- typedef typename Map::mapped_type mapped_type;
- typedef typename Map::value_type value_type;
- typedef typename Map::key_type key_type;
- typedef typename Map::size_type size_type;
-
- private:
- Implementation impl;
- Predicate pred; ///< do we really need to store a copy of the predicate? used in operator[]
-
- public:
-
- map() { }
- map(Allocator const &A)
- : impl(Predicate(), A) { }
- map(Predicate Pr, Allocator A = Allocator())
- : impl(Pr, A), pred(Pr) { }
- map(const map& other)
- : impl(other.impl), pred(other.pred) { }
- template <class II>
- map(II F, II L, Predicate const &Pr = Predicate(), Allocator A = Allocator())
- : impl(F,L,Pr,A), pred(Pr) { }
-
- Allocator get_allocator() const
- {
- return impl.get_allocator();
- }
- void clear()
- {
- impl.clear();
- }
- size_type size() const
- {
- return impl.size();
- }
- bool empty() const
- {
- return impl.empty();
- }
- iterator begin()
- {
- return impl.begin();
- }
- iterator end()
- {
- return impl.end();
- }
- const_iterator begin() const
- {
- return impl.begin();
- }
- const_iterator end() const
- {
- return impl.end();
- }
-
- void insert(const value_type& value)
- {
- impl.insert(value);
- }
- void erase(iterator first)
- {
- impl.erase(first);
- }
- void erase(iterator first, iterator last)
- {
- impl.erase(first, last);
- }
- size_type erase(key_type const &key)
- {
- return impl.erase(key);
- }
- mapped_type& operator[](const key_type& key)
- {
- iterator where = impl.lower_bound(key);
- if (where == impl.end() || pred(key, where->first))
- {
- where = impl.insert(where, value_type(key, Create::Given(this->Parent::get_storage())));
- }
- return where->second;
- }
- iterator find(key_type const &key)
- {
- return impl.find(key);
- }
- const_iterator find(key_type const &key) const
- {
- return impl.find(key);
- }
- };
+ namespace monotonic
+ {
+ /// A map that uses a monotonic allocator
+ template <class K // key-type
+ , class T // value-type
+ , class Region = default_region_tag // allocation region
+ , class P = std::less<K> // predicate
+ , class Access = default_access_tag // access type
+ >
+ struct map : detail::container<map<K,T,Region,P,Access> >
+ {
+ typedef P Predicate;
+ typedef allocator<K,Region,Access> Allocator;
+ typedef detail::container<map<K,T,Region,P,Access> > Parent;
+ typedef detail::Create<detail::is_monotonic<T>::value, T> Create;
+
+ typedef std::map<K,T,P,Allocator > Map, Implementation;
+ typedef typename Map::iterator iterator;
+ typedef typename Map::const_iterator const_iterator;
+ typedef typename Map::mapped_type mapped_type;
+ typedef typename Map::value_type value_type;
+ typedef typename Map::key_type key_type;
+ typedef typename Map::size_type size_type;
+
+ private:
+ Implementation impl;
+ Predicate pred; ///< do we really need to store a copy of the predicate? used in operator[]
+
+ public:
+
+ map() { }
+ map(Allocator const &A)
+ : impl(Predicate(), A) { }
+ map(Predicate Pr, Allocator A = Allocator())
+ : impl(Pr, A), pred(Pr) { }
+ map(const map& other)
+ : impl(other.impl), pred(other.pred) { }
+ template <class II>
+ map(II F, II L, Predicate const &Pr = Predicate(), Allocator A = Allocator())
+ : impl(F,L,Pr,A), pred(Pr) { }
+
+ Allocator get_allocator() const
+ {
+ return impl.get_allocator();
+ }
+ void clear()
+ {
+ impl.clear();
+ }
+ size_type size() const
+ {
+ return impl.size();
+ }
+ bool empty() const
+ {
+ return impl.empty();
+ }
+ iterator begin()
+ {
+ return impl.begin();
+ }
+ iterator end()
+ {
+ return impl.end();
+ }
+ const_iterator begin() const
+ {
+ return impl.begin();
+ }
+ const_iterator end() const
+ {
+ return impl.end();
+ }
+
+ void insert(const value_type& value)
+ {
+ impl.insert(value);
+ }
+ void erase(iterator first)
+ {
+ impl.erase(first);
+ }
+ void erase(iterator first, iterator last)
+ {
+ impl.erase(first, last);
+ }
+ size_type erase(key_type const &key)
+ {
+ return impl.erase(key);
+ }
+ mapped_type& operator[](const key_type& key)
+ {
+ iterator where = impl.lower_bound(key);
+ if (where == impl.end() || pred(key, where->first))
+ {
+ where = impl.insert(where, value_type(key, Create::Given(this->Parent::get_storage())));
+ }
+ return where->second;
+ }
+ iterator find(key_type const &key)
+ {
+ return impl.find(key);
+ }
+ const_iterator find(key_type const &key) const
+ {
+ return impl.find(key);
+ }
+ };
 
- } // namespace monotonic
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/monotonic/containers/ptr_list.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/containers/ptr_list.hpp (original)
+++ sandbox/monotonic/boost/monotonic/containers/ptr_list.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -13,26 +13,26 @@
 
 namespace boost
 {
- namespace monotonic
- {
- /// A boost::ptr_list<T> that uses a monotonic allocator, and a custom clone allocator
- /// TODO: not use inheritance
- template <class T, class Region, class Access>
- struct ptr_list : boost::ptr_list<T, inline_clone_allocator, allocator<T,Region,Access> >
- {
- typedef allocator<T,Region,Access> Allocator;
- typedef boost::ptr_list<T, inline_clone_allocator, Allocator> List;
-
- ptr_list()
- {
- }
- ptr_list(Allocator const &A)
- : List(A)
- {
- }
- };
+ namespace monotonic
+ {
+ /// A boost::ptr_list<T> that uses a monotonic allocator, and a custom clone allocator
+ /// TODO: not use inheritance
+ template <class T, class Region, class Access>
+ struct ptr_list : boost::ptr_list<T, inline_clone_allocator, allocator<T,Region,Access> >
+ {
+ typedef allocator<T,Region,Access> Allocator;
+ typedef boost::ptr_list<T, inline_clone_allocator, Allocator> List;
+
+ ptr_list()
+ {
+ }
+ ptr_list(Allocator const &A)
+ : List(A)
+ {
+ }
+ };
 
- } // namespace monotonic
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/monotonic/containers/set.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/containers/set.hpp (original)
+++ sandbox/monotonic/boost/monotonic/containers/set.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -12,98 +12,98 @@
 
 namespace boost
 {
- namespace monotonic
- {
- /// A std::set<T,P> that uses a monotonic allocator
- template <class T
- , class Region = default_region_tag // allocation region
- , class P = std::less<T> // predicate
- , class Access = default_access_tag> // access type
- struct set : detail::container<set<T,Region,P,Access> >
- {
- typedef allocator<T,Region,Access> Allocator;
- typedef P Predicate;
- typedef interprocess::set<T,P,Allocator > Set;
- typedef typename Set::iterator iterator;
- typedef typename Set::const_iterator const_iterator;
- typedef typename Set::value_type value_type;
- typedef typename Set::key_type key_type;
- typedef typename Set::size_type size_type;
- typedef detail::Create<detail::is_monotonic<T>::value, T> Create;
- typedef detail::container<set<T,Region,P,Access> > Parent;
-
- private:
- Set impl;
-
- public:
- set() { }
- set(Allocator A)
- : impl(Predicate(), A) { }
- set(Predicate Pr, Allocator A)
- : impl(Pr, A) { }
- template <class II>
- set(II F, II L, Allocator A = Allocator())
- : impl(F,L,Predicate(),A) { }
- template <class II>
- set(II F, II L, Predicate Pr, Allocator A = Allocator())
- : impl(F,L,Pr,A) { }
-
- Allocator get_allocator() const
- {
- return impl.get_allocator();
- }
- void clear()
- {
- impl.clear();
- }
- size_type size() const
- {
- return impl.size();
- }
- bool empty() const
- {
- return impl.empty();
- }
- iterator begin()
- {
- return impl.begin();
- }
- iterator end()
- {
- return impl.end();
- }
- const_iterator begin() const
- {
- return impl.begin();
- }
- const_iterator end() const
- {
- return impl.end();
- }
-
- void insert(const value_type& value)
- {
- impl.insert(Create::Given(this->Parent::get_storage(), value));
- }
- void erase(iterator first)
- {
- impl.erase(first);
- }
- void erase(iterator first, iterator last)
- {
- impl.erase(first, last);
- }
- iterator find(value_type const &key)
- {
- return impl.find(key);
- }
- const_iterator find(value_type const &key) const
- {
- return impl.find(key);
- }
- };
+ namespace monotonic
+ {
+ /// A std::set<T,P> that uses a monotonic allocator
+ template <class T
+ , class Region = default_region_tag // allocation region
+ , class P = std::less<T> // predicate
+ , class Access = default_access_tag> // access type
+ struct set : detail::container<set<T,Region,P,Access> >
+ {
+ typedef allocator<T,Region,Access> Allocator;
+ typedef P Predicate;
+ typedef interprocess::set<T,P,Allocator > Set;
+ typedef typename Set::iterator iterator;
+ typedef typename Set::const_iterator const_iterator;
+ typedef typename Set::value_type value_type;
+ typedef typename Set::key_type key_type;
+ typedef typename Set::size_type size_type;
+ typedef detail::Create<detail::is_monotonic<T>::value, T> Create;
+ typedef detail::container<set<T,Region,P,Access> > Parent;
+
+ private:
+ Set impl;
+
+ public:
+ set() { }
+ set(Allocator A)
+ : impl(Predicate(), A) { }
+ set(Predicate Pr, Allocator A)
+ : impl(Pr, A) { }
+ template <class II>
+ set(II F, II L, Allocator A = Allocator())
+ : impl(F,L,Predicate(),A) { }
+ template <class II>
+ set(II F, II L, Predicate Pr, Allocator A = Allocator())
+ : impl(F,L,Pr,A) { }
+
+ Allocator get_allocator() const
+ {
+ return impl.get_allocator();
+ }
+ void clear()
+ {
+ impl.clear();
+ }
+ size_type size() const
+ {
+ return impl.size();
+ }
+ bool empty() const
+ {
+ return impl.empty();
+ }
+ iterator begin()
+ {
+ return impl.begin();
+ }
+ iterator end()
+ {
+ return impl.end();
+ }
+ const_iterator begin() const
+ {
+ return impl.begin();
+ }
+ const_iterator end() const
+ {
+ return impl.end();
+ }
+
+ void insert(const value_type& value)
+ {
+ impl.insert(Create::Given(this->Parent::get_storage(), value));
+ }
+ void erase(iterator first)
+ {
+ impl.erase(first);
+ }
+ void erase(iterator first, iterator last)
+ {
+ impl.erase(first, last);
+ }
+ iterator find(value_type const &key)
+ {
+ return impl.find(key);
+ }
+ const_iterator find(value_type const &key) const
+ {
+ return impl.find(key);
+ }
+ };
 
- } // namespace monotonic
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/monotonic/containers/string.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/containers/string.hpp (original)
+++ sandbox/monotonic/boost/monotonic/containers/string.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -12,128 +12,128 @@
 
 namespace boost
 {
- namespace monotonic
- {
- /// a string that uses a monotonic allocator in the given region
- template <class Region = default_region_tag, class Access = default_access_tag>
- struct string : detail::container<string<Region,Access> >
- {
- typedef char Ch;
- typedef std::char_traits<Ch> Tr;
- typedef allocator<Ch, Region,Access> Allocator;
- typedef std::basic_string<Ch, Tr, Allocator> Impl;
- typedef size_t size_type;
- typedef typename Impl::iterator iterator;
- typedef typename Impl::const_iterator const_iterator;
- typedef typename Impl::value_type value_type;
-
- private:
- Impl impl;
-
- public:
- string()
- {
- }
- template <class Reg2, class Acc2>
- string(string<Reg2,Acc2> const &other)
- : impl(other.impl)
- {
- }
- string(Allocator alloc)
- : impl(alloc)
- {
- }
- string(const Ch *str)
- : impl(str)
- {
- }
- template <class U>
- string(const Ch *str, allocator<U,Region,Access> alloc)
- : impl(str, alloc)
- {
- }
- string(const Ch *str, storage_base &store)
- : impl(str, store)
- {
-// BOOST_STATIC_ASSERT((boost::same_type<default_region_tag, Region>::value));
- }
- template <class II>
- string(II F, II L)
- : impl(F, L)
- {
- }
- template <class II, class U>
- string(II F, II L, allocator<U,Region,Access> alloc)
- : 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
- {
- return impl;
- }
- Impl &get_impl()
- {
- return impl;
- }
-
- template <class Reg2, class Acc2>
- string &operator=(string<Reg2,Acc2> const &other)
- {
- impl = other.c_str();
- return *this;
- }
-
- string &operator+=(Ch const *str)
- {
- impl += str;
- return *this;
- }
-
- Ch const *c_str() const
- {
- return impl.c_str();
- }
- };
-
- template <class Reg, class Acc>
- bool operator==(string<Reg,Acc> const &A, string<Reg,Acc> const &B)
- {
- return A.get_impl() == B.get_impl();
- }
- template <class Reg, class Acc, class Reg2, class Acc2>
- bool operator==(string<Reg,Acc> const &A, string<Reg2,Acc2> const &B)
- {
- return A.get_impl() == B.c_str();
- }
- template <class Reg, class Acc>
- bool operator==(string<Reg,Acc> const &A, typename string<Reg,Acc>::value_type const *B)
- {
- return A.get_impl() == B;
- }
- template <class Reg, class Acc, class Reg2, class Acc2>
- bool operator<(string<Reg,Acc> const &A, string<Reg2,Acc2> const &B)
- {
- return A.get_impl() < B.get_impl();
- }
+ namespace monotonic
+ {
+ /// a string that uses a monotonic allocator in the given region
+ template <class Region = default_region_tag, class Access = default_access_tag>
+ struct string : detail::container<string<Region,Access> >
+ {
+ typedef char Ch;
+ typedef std::char_traits<Ch> Tr;
+ typedef allocator<Ch, Region,Access> Allocator;
+ typedef std::basic_string<Ch, Tr, Allocator> Impl;
+ typedef size_t size_type;
+ typedef typename Impl::iterator iterator;
+ typedef typename Impl::const_iterator const_iterator;
+ typedef typename Impl::value_type value_type;
+
+ private:
+ Impl impl;
+
+ public:
+ string()
+ {
+ }
+ template <class Reg2, class Acc2>
+ string(string<Reg2,Acc2> const &other)
+ : impl(other.impl)
+ {
+ }
+ string(Allocator alloc)
+ : impl(alloc)
+ {
+ }
+ string(const Ch *str)
+ : impl(str)
+ {
+ }
+ template <class U>
+ string(const Ch *str, allocator<U,Region,Access> alloc)
+ : impl(str, alloc)
+ {
+ }
+ string(const Ch *str, storage_base &store)
+ : impl(str, store)
+ {
+// BOOST_STATIC_ASSERT((boost::same_type<default_region_tag, Region>::value));
+ }
+ template <class II>
+ string(II F, II L)
+ : impl(F, L)
+ {
+ }
+ template <class II, class U>
+ string(II F, II L, allocator<U,Region,Access> alloc)
+ : 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
+ {
+ return impl;
+ }
+ Impl &get_impl()
+ {
+ return impl;
+ }
+
+ template <class Reg2, class Acc2>
+ string &operator=(string<Reg2,Acc2> const &other)
+ {
+ impl = other.c_str();
+ return *this;
+ }
+
+ string &operator+=(Ch const *str)
+ {
+ impl += str;
+ return *this;
+ }
+
+ Ch const *c_str() const
+ {
+ return impl.c_str();
+ }
+ };
+
+ template <class Reg, class Acc>
+ bool operator==(string<Reg,Acc> const &A, string<Reg,Acc> const &B)
+ {
+ return A.get_impl() == B.get_impl();
+ }
+ template <class Reg, class Acc, class Reg2, class Acc2>
+ bool operator==(string<Reg,Acc> const &A, string<Reg2,Acc2> const &B)
+ {
+ return A.get_impl() == B.c_str();
+ }
+ template <class Reg, class Acc>
+ bool operator==(string<Reg,Acc> const &A, typename string<Reg,Acc>::value_type const *B)
+ {
+ return A.get_impl() == B;
+ }
+ template <class Reg, class Acc, class Reg2, class Acc2>
+ bool operator<(string<Reg,Acc> const &A, string<Reg2,Acc2> const &B)
+ {
+ return A.get_impl() < B.get_impl();
+ }
 
- } // namespace monotonic
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/monotonic/containers/vector.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/containers/vector.hpp (original)
+++ sandbox/monotonic/boost/monotonic/containers/vector.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -13,169 +13,169 @@
 
 namespace boost
 {
- namespace monotonic
- {
- /// a vector that uses a monotonic allocator in the given region, with given access system
- template <class T, class Region = default_region_tag, class Access = default_access_tag>
- struct vector : detail::container<vector<T,Region,Access> >
- {
- typedef allocator<T,Region,Access> Allocator;
- typedef detail::container<std::vector<T, Allocator > > Parent;
- typedef detail::Create<detail::is_monotonic<T>::value, T> Create;
- //typedef interprocess::vector<T,Allocator> Impl;
- typedef std::vector<T,Allocator> Impl;
-
- typedef typename Impl::iterator iterator;
- typedef typename Impl::const_iterator const_iterator;
- typedef typename Impl::size_type size_type;
- typedef typename Impl::value_type value_type;
- typedef typename Impl::reference reference;
- typedef typename Impl::const_reference const_reference;
-
- private:
- Impl impl;
-
- public:
- vector() { }
- vector(Allocator const &A)
- : impl(A) { }
- vector(vector const &other, Allocator A)
- : impl(A)
- {
- impl = other.impl;
- }
- vector(size_t N, T const &X, Allocator A = Allocator())
- : impl(N,X,A) { }
- template <class II>
- vector(II F, II L, Allocator A = Allocator())
- : impl(F,L,A) { }
-
- Allocator get_allocator() const
- {
- return impl.get_allocator();
- }
- Impl const &get_impl() const
- {
- return impl;
- }
- Impl &get_impl()
- {
- return impl;
- }
- bool empty() const
- {
- return impl.empty();
- }
- size_type size() const
- {
- return impl.size();
- }
- void resize(size_type size)
- {
- impl.resize(size);//, Creator::Create(GetStorage()));
- }
- void reserve(size_type size)
- {
- impl.reserve(size);
- }
- size_type capacity() const
- {
- return impl.capacity();
- }
- reference at(size_type index)
- {
- return impl.at(index);
- }
- const_reference at(size_type index) const
- {
- return impl.at(index);
- }
- reference operator[](size_type index)
- {
- return impl[index];
- }
- const_reference operator[](size_type index) const
- {
- return impl[index];
- }
- void push_back(value_type const &value)
- {
- impl.push_back(value);
- }
- void pop_back()
- {
- impl.pop_back();
- }
- iterator begin()
- {
- return impl.begin();
- }
- iterator end()
- {
- return impl.end();
- }
- const_iterator begin() const
- {
- return impl.begin();
- }
- const_iterator end() const
- {
- return impl.end();
- }
- value_type const &front() const
- {
- return impl.front();
- }
- value_type &front()
- {
- return impl.front();
- }
- value_type const &back() const
- {
- return impl.back();
- }
- value_type &back()
- {
- return impl.back();
- }
-
- void swap(vector &other)
- {
- impl.swap(other.impl);
- }
- };
-
- template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
- bool operator==(vector<Ty,R,Acc> const &A, vector<Ty2,R2,Acc2> const &B)
- {
- return A.size() == B.size() && std::equal(A.begin(), A.end(), B.begin());
- }
- template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
- bool operator!=(vector<Ty,R,Acc> const &A, vector<Ty2,R2,Acc2> const &B)
- {
- return !(A == B);
- }
- template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
- bool operator<(vector<Ty,R,Acc> const &A, vector<Ty2,R2,Acc2> const &B)
- {
- return std::lexicographical_compare(A.begin(), A.end(), B.begin(), B.end());
- }
- template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
- bool operator>(vector<Ty,R,Acc> const &A, vector<Ty2,R2,Acc2> const &B)
- {
- return std::lexicographical_compare(B.begin(), B.end(), A.begin(), A.end());
- }
- template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
- bool operator<=(vector<Ty,R,Acc> const &A, vector<Ty2,R2,Acc2> const &B)
- {
- return !(A > B);
- }
- template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
- bool operator>=(vector<Ty,R,Acc> const &A, vector<Ty2,R2,Acc2> const &B)
- {
- return !(A < B);
- }
- } // namespace monotonic
+ namespace monotonic
+ {
+ /// a vector that uses a monotonic allocator in the given region, with given access system
+ template <class T, class Region = default_region_tag, class Access = default_access_tag>
+ struct vector : detail::container<vector<T,Region,Access> >
+ {
+ typedef allocator<T,Region,Access> Allocator;
+ typedef detail::container<std::vector<T, Allocator > > Parent;
+ typedef detail::Create<detail::is_monotonic<T>::value, T> Create;
+ //typedef interprocess::vector<T,Allocator> Impl;
+ typedef std::vector<T,Allocator> Impl;
+
+ typedef typename Impl::iterator iterator;
+ typedef typename Impl::const_iterator const_iterator;
+ typedef typename Impl::size_type size_type;
+ typedef typename Impl::value_type value_type;
+ typedef typename Impl::reference reference;
+ typedef typename Impl::const_reference const_reference;
+
+ private:
+ Impl impl;
+
+ public:
+ vector() { }
+ vector(Allocator const &A)
+ : impl(A) { }
+ vector(vector const &other, Allocator A)
+ : impl(A)
+ {
+ impl = other.impl;
+ }
+ vector(size_t N, T const &X, Allocator A = Allocator())
+ : impl(N,X,A) { }
+ template <class II>
+ vector(II F, II L, Allocator A = Allocator())
+ : impl(F,L,A) { }
+
+ Allocator get_allocator() const
+ {
+ return impl.get_allocator();
+ }
+ Impl const &get_impl() const
+ {
+ return impl;
+ }
+ Impl &get_impl()
+ {
+ return impl;
+ }
+ bool empty() const
+ {
+ return impl.empty();
+ }
+ size_type size() const
+ {
+ return impl.size();
+ }
+ void resize(size_type size)
+ {
+ impl.resize(size);//, Creator::Create(GetStorage()));
+ }
+ void reserve(size_type size)
+ {
+ impl.reserve(size);
+ }
+ size_type capacity() const
+ {
+ return impl.capacity();
+ }
+ reference at(size_type index)
+ {
+ return impl.at(index);
+ }
+ const_reference at(size_type index) const
+ {
+ return impl.at(index);
+ }
+ reference operator[](size_type index)
+ {
+ return impl[index];
+ }
+ const_reference operator[](size_type index) const
+ {
+ return impl[index];
+ }
+ void push_back(value_type const &value)
+ {
+ impl.push_back(value);
+ }
+ void pop_back()
+ {
+ impl.pop_back();
+ }
+ iterator begin()
+ {
+ return impl.begin();
+ }
+ iterator end()
+ {
+ return impl.end();
+ }
+ const_iterator begin() const
+ {
+ return impl.begin();
+ }
+ const_iterator end() const
+ {
+ return impl.end();
+ }
+ value_type const &front() const
+ {
+ return impl.front();
+ }
+ value_type &front()
+ {
+ return impl.front();
+ }
+ value_type const &back() const
+ {
+ return impl.back();
+ }
+ value_type &back()
+ {
+ return impl.back();
+ }
+
+ void swap(vector &other)
+ {
+ impl.swap(other.impl);
+ }
+ };
+
+ template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
+ bool operator==(vector<Ty,R,Acc> const &A, vector<Ty2,R2,Acc2> const &B)
+ {
+ return A.size() == B.size() && std::equal(A.begin(), A.end(), B.begin());
+ }
+ template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
+ bool operator!=(vector<Ty,R,Acc> const &A, vector<Ty2,R2,Acc2> const &B)
+ {
+ return !(A == B);
+ }
+ template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
+ bool operator<(vector<Ty,R,Acc> const &A, vector<Ty2,R2,Acc2> const &B)
+ {
+ return std::lexicographical_compare(A.begin(), A.end(), B.begin(), B.end());
+ }
+ template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
+ bool operator>(vector<Ty,R,Acc> const &A, vector<Ty2,R2,Acc2> const &B)
+ {
+ return std::lexicographical_compare(B.begin(), B.end(), A.begin(), A.end());
+ }
+ template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
+ bool operator<=(vector<Ty,R,Acc> const &A, vector<Ty2,R2,Acc2> const &B)
+ {
+ return !(A > B);
+ }
+ template <class Ty,class R,class Acc,class Ty2,class R2,class Acc2>
+ bool operator>=(vector<Ty,R,Acc> const &A, vector<Ty2,R2,Acc2> const &B)
+ {
+ return !(A < B);
+ }
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/monotonic/detail/construct.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/detail/construct.hpp (original)
+++ sandbox/monotonic/boost/monotonic/detail/construct.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -8,86 +8,86 @@
 
 namespace boost
 {
- namespace monotonic
- {
- namespace detail
- {
- template <bool is_mono_container>
- struct Construct
- {
- template <class T, class Alloc>
- static void Given(T *ptr, Alloc *allocator)
- {
- new (ptr) T();
- }
- template <class T, class Alloc>
- static void Given(T *ptr, T const &val, Alloc *allocator)
- {
- new (ptr) T(val);
- }
- };
- template <>
- struct Construct<true>
- {
- template <class T, class Alloc>
- static void Given(T *ptr, Alloc *allocator)
- {
- new (ptr) T(*allocator);
- }
- template <class T, class Alloc>
- static void Given(T *ptr, T const &val, Alloc *allocator)
- {
- // unfortunately, there is no requirement for a container to
- // have a copy-ctor that also passes an allocator.
- new (ptr) T(*allocator);
- *ptr = val;
- }
- };
-
- template <bool is_monotonic_container, class T>
- struct Create
- {
- template <class Storage>
- static T Given(Storage &)
- {
- return T();
- }
- template <class Storage>
- static T Given(Storage &, T const &X)
- {
- return T(X);
- }
- };
- template <class T>
- struct Create<true, T>
- {
- template <class Storage>
- static T Given(Storage &storage)
- {
- return T(storage);
- }
- template <class Storage>
- static T Given(Storage &storage, T const &X)
- {
- return T(X, storage);
- }
- };
- }
- namespace detail
- {
- template <size_t A, size_t B>
- struct miniumum
- {
- BOOST_STATIC_CONSTANT(size_t, value = A < B ? A : B);
- };
- template <size_t A, size_t B>
- struct maximum
- {
- BOOST_STATIC_CONSTANT(size_t, value = B < A ? A : B);
- };
- } // namespace detail
+ namespace monotonic
+ {
+ namespace detail
+ {
+ template <bool is_mono_container>
+ struct Construct
+ {
+ template <class T, class Alloc>
+ static void Given(T *ptr, Alloc *allocator)
+ {
+ new (ptr) T();
+ }
+ template <class T, class Alloc>
+ static void Given(T *ptr, T const &val, Alloc *allocator)
+ {
+ new (ptr) T(val);
+ }
+ };
+ template <>
+ struct Construct<true>
+ {
+ template <class T, class Alloc>
+ static void Given(T *ptr, Alloc *allocator)
+ {
+ new (ptr) T(*allocator);
+ }
+ template <class T, class Alloc>
+ static void Given(T *ptr, T const &val, Alloc *allocator)
+ {
+ // unfortunately, there is no requirement for a container to
+ // have a copy-ctor that also passes an allocator.
+ new (ptr) T(*allocator);
+ *ptr = val;
+ }
+ };
+
+ template <bool is_monotonic_container, class T>
+ struct Create
+ {
+ template <class Storage>
+ static T Given(Storage &)
+ {
+ return T();
+ }
+ template <class Storage>
+ static T Given(Storage &, T const &X)
+ {
+ return T(X);
+ }
+ };
+ template <class T>
+ struct Create<true, T>
+ {
+ template <class Storage>
+ static T Given(Storage &storage)
+ {
+ return T(storage);
+ }
+ template <class Storage>
+ static T Given(Storage &storage, T const &X)
+ {
+ return T(X, storage);
+ }
+ };
+ }
+ namespace detail
+ {
+ template <size_t A, size_t B>
+ struct miniumum
+ {
+ BOOST_STATIC_CONSTANT(size_t, value = A < B ? A : B);
+ };
+ template <size_t A, size_t B>
+ struct maximum
+ {
+ BOOST_STATIC_CONSTANT(size_t, value = B < A ? A : B);
+ };
+ } // namespace detail
 
- } // namespace monotonic
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/monotonic/detail/container.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/detail/container.hpp (original)
+++ sandbox/monotonic/boost/monotonic/detail/container.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -11,39 +11,39 @@
 
 namespace boost
 {
- namespace monotonic
- {
- namespace detail
- {
- struct container_base { virtual ~container_base() { } };
-
- template <class Impl>
- struct container;
-
- template <class T>
- struct is_monotonic : mpl::bool_<is_convertible<T *, container_base *>::value> { };
-
- template <class Impl>
- struct is_monotonic<container<Impl> > : mpl::true_ { };
-
- template <class Impl>
- struct container : container_base
- {
- typedef Impl Derived;
-
- storage_base &get_storage() const
- {
- Derived const &self = static_cast<Derived const &>(*this);
- storage_base *store = self.get_allocator().get_storage();
- if (store == 0)
- //throw_exception(no_storage());
- throw no_storage();
- return *store;
- }
- };
+ namespace monotonic
+ {
+ namespace detail
+ {
+ struct container_base { virtual ~container_base() { } };
+
+ template <class Impl>
+ struct container;
+
+ template <class T>
+ struct is_monotonic : mpl::bool_<is_convertible<T *, container_base *>::value> { };
+
+ template <class Impl>
+ struct is_monotonic<container<Impl> > : mpl::true_ { };
+
+ template <class Impl>
+ struct container : container_base
+ {
+ typedef Impl Derived;
+
+ storage_base &get_storage() const
+ {
+ Derived const &self = static_cast<Derived const &>(*this);
+ storage_base *store = self.get_allocator().get_storage();
+ if (store == 0)
+ //throw_exception(no_storage());
+ throw no_storage();
+ return *store;
+ }
+ };
 
- }
- }
+ }
+ }
 }
 
 #include <boost/monotonic/detail/postfix.hpp>

Modified: sandbox/monotonic/boost/monotonic/detail/link.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/detail/link.hpp (original)
+++ sandbox/monotonic/boost/monotonic/detail/link.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -8,75 +8,83 @@
 
 namespace boost
 {
- namespace monotonic
- {
- namespace detail
- {
- /// a link in the chain of heap-based memory buffers used by a storage<> structure
- template <class Al>
- struct Link// : storage_base
- {
- typedef Al CharAllocator;
-
- private:
- size_t capacity, cursor;
- char *buffer;
- CharAllocator alloc;
-
- public:
- Link() : capacity(0), cursor(0), buffer(0)
- {
- }
- template <class Al2>
- Link(Al2 const &al, size_t cap)
- : capacity(cap), cursor(0), buffer(0)
- , alloc(typename Al2::template rebind<char>::other(al))
- {
- buffer = alloc.allocate(capacity);
- if (buffer == 0)
- capacity = 0;
- }
- size_t max_size() const
- {
- return capacity;
- }
- size_t remaining() const
- {
- return capacity - cursor;
- }
- void reset()
- {
- cursor = 0;
- }
- void release()
- {
- alloc.deallocate(buffer, 1);
- }
- size_t used() const
- {
- return cursor;
- }
- inline void *allocate(size_t num_bytes, size_t alignment)
- {
- size_t extra = cursor & (alignment - 1);
- if (extra > 0)
- extra = alignment - extra;
- size_t required = num_bytes + extra;
- if (capacity - cursor < required)
- return 0;
- char *ptr = buffer + cursor;
- cursor += required;
- return ptr + extra;
- }
- friend bool operator<(Link const &A, Link const &B)
- {
- return A.remaining() < B.remaining();
- }
- };
+ namespace monotonic
+ {
+ namespace detail
+ {
+ /// a link in the chain of heap-based memory buffers used by a storage<> structure
+ template <class Al>
+ struct Link// : storage_base
+ {
+ typedef Al CharAllocator;
+
+ private:
+ size_t capacity, cursor;
+ char *buffer;
+ CharAllocator alloc;
+
+ public:
+ Link() : capacity(0), cursor(0), buffer(0)
+ {
+ }
+ template <class Al2>
+ Link(Al2 const &al, size_t cap)
+ : capacity(cap), cursor(0), buffer(0)
+ , alloc(typename Al2::template rebind<char>::other(al))
+ {
+ buffer = alloc.allocate(capacity);
+ if (buffer == 0)
+ capacity = 0;
+ }
+ size_t max_size() const
+ {
+ return capacity;
+ }
+ size_t remaining() const
+ {
+ return capacity - cursor;
+ }
+ size_t get_cursor() const
+ {
+ return cursor;
+ }
+ void set_cursor(size_t C)
+ {
+ cursor = C;
+ }
+ void reset()
+ {
+ cursor = 0;
+ }
+ void release()
+ {
+ alloc.deallocate(buffer, 1);
+ }
+ size_t used() const
+ {
+ return cursor;
+ }
+ inline void *allocate(size_t num_bytes, size_t alignment)
+ {
+ size_t extra = cursor & (alignment - 1);
+ if (extra > 0)
+ extra = alignment - extra;
+ size_t required = num_bytes + extra;
+ if (capacity - cursor < required)
+ return 0;
+ char *ptr = buffer + cursor;
+ cursor += required;
+ return ptr + extra;
+ }
+ friend bool operator<(Link const &A, Link const &B)
+ {
+ return A.remaining() < B.remaining();
+ }
+ };
 
- } // namespace detail
+ } // namespace detail
 
- } // namespace monotonic
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/monotonic/detail/pool.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/detail/pool.hpp (original)
+++ sandbox/monotonic/boost/monotonic/detail/pool.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -8,57 +8,61 @@
 
 namespace boost
 {
- namespace monotonic
- {
- namespace detail
- {
- /// a pool of same-sized chunks in a storage block
- struct Pool
- {
- char *first, *next, *last;
- size_t bucket_size;
- Pool() : first(0), next(0), last(0), bucket_size(0)
- {
- }
- Pool(size_t bs) : first(0), next(0), last(0), bucket_size(bs)
- {
- }
- template <class Storage>
- void *allocate(Storage &storage)
- {
- if (next == last && !expand(storage))
- return 0;
- void *ptr = next;
- next += bucket_size;
- return ptr;
- }
- template <class Storage>
- bool expand(Storage &storage)
- {
- size_t capacity = (std::max)(DefaultSizes::MinPoolSize*bucket_size, (last - first)*bucket_size*2);
- void *ptr = storage.from_fixed(capacity, 16);
- if (ptr == 0)
- {
- ptr = storage.from_heap(capacity, 16);
- if (ptr == 0)
- return false;
- }
- first = next = (char *)ptr;
- last = first + capacity;
- return true;
- }
- void reset()
- {
- first = next = last = 0;
- }
- };
+ namespace monotonic
+ {
+ namespace detail
+ {
+ /// a pool of same-sized chunks in a storage block
+ struct Pool
+ {
+ char *first, *next, *last;
+ size_t bucket_size;
+ Pool() : first(0), next(0), last(0), bucket_size(0)
+ {
+ }
+ Pool(size_t bs) : first(0), next(0), last(0), bucket_size(bs)
+ {
+ }
+ template <class Storage>
+ void *allocate(Storage &storage)
+ {
+ if (next == last && !expand(storage))
+ return 0;
+ void *ptr = next;
+ next += bucket_size;
+ return ptr;
+ }
+ void pop()
+ {
+ next -= bucket_size;
+ }
+ template <class Storage>
+ bool expand(Storage &storage)
+ {
+ size_t capacity = (std::max)(DefaultSizes::MinPoolSize*bucket_size, (last - first)*bucket_size*2);
+ void *ptr = storage.from_fixed(capacity, 16);
+ if (ptr == 0)
+ {
+ ptr = storage.from_heap(capacity, 16);
+ if (ptr == 0)
+ return false;
+ }
+ first = next = (char *)ptr;
+ last = first + capacity;
+ return true;
+ }
+ void reset()
+ {
+ first = next = last = 0;
+ }
+ };
 
- } // namespace detail
+ } // namespace detail
 
- } // namespace monotonic
+ } // namespace monotonic
 
 } // namespace boost
-
+
 #endif // BOOST_MONOTONIC_DETAIL_POOL_HPP
 
 //EOF

Modified: sandbox/monotonic/boost/monotonic/detail/postfix.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/detail/postfix.hpp (original)
+++ sandbox/monotonic/boost/monotonic/detail/postfix.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -4,7 +4,7 @@
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
 #ifdef BOOST_MSVC
-# pragma warning(pop)
+# pragma warning(pop)
 #endif
 
 //EOF

Modified: sandbox/monotonic/boost/monotonic/detail/prefix.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/detail/prefix.hpp (original)
+++ sandbox/monotonic/boost/monotonic/detail/prefix.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -8,10 +8,10 @@
 #endif
 
 #ifdef BOOST_MSVC
-# pragma warning(push)
-# pragma warning(disable:4127) // conditional expression is constant
-# pragma warning(disable:4702) // unreachable code
-# pragma warning(disable:4996) // Function call with parameters that may be unsafe
+# pragma warning(push)
+# pragma warning(disable:4127) // conditional expression is constant
+# pragma warning(disable:4702) // unreachable code
+# pragma warning(disable:4996) // Function call with parameters that may be unsafe
 #endif
 
 //EOF

Modified: sandbox/monotonic/boost/monotonic/exceptions.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/exceptions.hpp (original)
+++ sandbox/monotonic/boost/monotonic/exceptions.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -12,16 +12,18 @@
 
 namespace boost
 {
- namespace monotonic
- {
- /// a request was made for a reference to storage that does not exist
- struct no_storage : std::exception
- {
- no_storage() { }
- //no_storage(const char *text) : std::exception(text) { }
- };
-
- } // namespace monotonic
+ namespace monotonic
+ {
+ /// a request was made for a reference to storage that does not exist
+ struct no_storage : std::exception
+ {
+ no_storage() { }
+ //no_storage(const char *text) : std::exception(text) { }
+ };
+
+ struct internal_error { };;
+
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/monotonic/fixed_storage.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/fixed_storage.hpp (original)
+++ sandbox/monotonic/boost/monotonic/fixed_storage.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -17,202 +17,231 @@
 
 namespace boost
 {
- namespace monotonic
- {
- /// storage for an allocator that is on the stack or heap
- template <size_t InlineSize>
- struct fixed_storage : storage_base
- {
- typedef boost::array<char, InlineSize> Buffer;
+ namespace monotonic
+ {
+ /// storage for an allocator that is on the stack or heap
+ template <size_t InlineSize>
+ struct fixed_storage : storage_base
+ {
+ typedef boost::array<char, InlineSize> Buffer;
 
- private:
- Buffer buffer; ///< the storage
+ private:
+ Buffer buffer; ///< the storage
 #ifdef BOOST_MONOTONIC_STORAGE_EARLY_OUT
- /// if `full` is true, buffer has reached its capacity; used for early-out on allocation.
- /// this maybe should be removed, because although it may speed up allocation
- /// a little when the buffer is full, it also slows it down a little when it is not
- bool full;
+ /// if `full` is true, buffer has reached its capacity; used for early-out on allocation.
+ /// this maybe should be removed, because although it may speed up allocation
+ /// a little when the buffer is full, it also slows it down a little when it is not
+ bool full;
 #endif
- size_t cursor; ///< pointer to current index within storage for next allocation
+ size_t cursor; ///< pointer to current index within storage for next allocation
 #ifndef NDEBUG
- size_t num_allocations;
+ size_t num_allocations;
 #endif
- public:
- fixed_storage()
- : cursor(0)
+ public:
+ fixed_storage()
+ : cursor(0)
 #ifdef BOOST_MONOTONIC_STORAGE_EARLY_OUT
- , full(false)
+ , full(false)
 #endif
 #ifndef NDEBUG
- , num_allocations(0)
+ , num_allocations(0)
 #endif
- {
- }
+ {
+ }
 
- Buffer const &get_buffer() const
- {
- return buffer;
- }
- const char *begin() const
- {
- return &buffer[0];
- }
- const char *end() const
- {
- return &buffer[InlineSize - 1];
- }
- void reset()
- {
- cursor = 0;
+ Buffer const &get_buffer() const
+ {
+ return buffer;
+ }
+ const char *begin() const
+ {
+ return &buffer[0];
+ }
+ const char *end() const
+ {
+ return &buffer[InlineSize - 1];
+ }
+ void reset()
+ {
+ cursor = 0;
 #ifdef BOOST_MONOTONIC_STORAGE_EARLY_OUT
- full = false;
+ full = false;
 #endif
 #ifndef NDEBUG
- num_allocations = 0;
+ num_allocations = 0;
 #endif
- }
- void release()
- {
- reset();
- }
-
- size_t get_cursor() const
- {
- return cursor;
- }
-
- void set_cursor(size_t c)
- {
- cursor = c;
- }
-
- // testing performance against a fixed-size alignment
- BOOST_STATIC_CONSTANT(size_t, alignment = 64);
-
- /// allocate storage, given alignment requirement
- void *allocate(size_t num_bytes, size_t /*alignment*/)
- {
+ }
+ void release()
+ {
+ reset();
+ }
+
+ size_t get_cursor() const
+ {
+ return cursor;
+ }
+
+ void set_cursor(size_t c)
+ {
+ cursor = c;
+ }
+
+ // testing performance against a fixed-size alignment
+ BOOST_STATIC_CONSTANT(size_t, alignment = 64);
+
+ //protected:
+ struct AllocationAttempt
+ {
+ bool able;
+ size_t required;
+ size_t extra;
+ AllocationAttempt() : able(false) { }
+ AllocationAttempt(size_t R, size_t E) : able(true), required(R), extra(E) { }
+ };
+
+ AllocationAttempt TryAllocation(size_t num_bytes, size_t alignment)
+ {
+ size_t extra = cursor & (alignment - 1);
+ if (extra > 0)
+ extra = alignment - extra;
+ size_t required = num_bytes + extra;
+ if (cursor + required > InlineSize)
+ return AllocationAttempt();
+ return AllocationAttempt(required, extra);
+ }
+
+ void *MakeAllocation(AllocationAttempt const &ad)
+ {
+ char *ptr = &buffer[cursor];
+ cursor += ad.required;
+ return ptr + ad.extra;
+ }
+
+ public:
+ /// allocate storage, given alignment requirement
+ void *allocate(size_t num_bytes, size_t alignment)
+ {
 #ifdef BOOST_MONOTONIC_STORAGE_EARLY_OUT
- if (full)
- return 0;
+ if (full)
+ return 0;
 #endif
 
- size_t extra = cursor & (alignment - 1);
- if (extra > 0)
- extra = alignment - extra;
- size_t required = num_bytes + extra;
- if (cursor + required > InlineSize)
- {
+ size_t extra = cursor & (alignment - 1);
+ if (extra > 0)
+ extra = alignment - extra;
+ size_t required = num_bytes + extra;
+ if (cursor + required > InlineSize)
+ {
 #ifdef BOOST_MONOTONIC_STORAGE_EARLY_OUT
- full = InlineSize - cursor < 16;
+ full = InlineSize - cursor < 16;
 #endif
- return 0;
- }
+ return 0;
+ }
 #ifndef NDEBUG
- ++num_allocations;
+ ++num_allocations;
 #endif
- char *ptr = &buffer[cursor];
- cursor += required;
- return ptr + extra;
- }
-
- void deallocate(void *ptr)
- {
- // do nothing
- }
-
- size_t max_size() const
- {
- return InlineSize;
- }
-
- size_t remaining() const
- {
- return InlineSize - cursor;
- }
-
- size_t used() const
- {
- return cursor;
- }
+ char *ptr = &buffer[cursor];
+ cursor += required;
+ return ptr + extra;
+ }
+
+ void deallocate(void *ptr)
+ {
+ // do nothing
+ }
+
+ size_t max_size() const
+ {
+ return InlineSize;
+ }
+
+ size_t remaining() const
+ {
+ return InlineSize - cursor;
+ }
+
+ size_t used() const
+ {
+ return cursor;
+ }
 
 #ifndef NDEBUG
- size_t get_num_allocs() const
- {
- return num_allocations;
- }
-#endif
- //-----------------------------------------------------------------
-
-
- template <class Ty>
- Ty *uninitialised_create()
- {
- return reinterpret_cast<Ty *>(allocate_bytes<sizeof(Ty)>());
- }
-
- template <class Ty>
- void construct(Ty *ptr, const boost::true_type& /*is_pod*/)
- {
- // do nothing
- }
-
- template <class Ty>
- void construct(Ty *ptr, const boost::false_type&)
- {
- new (ptr) Ty();
- }
-
- template <class Ty>
- Ty &create()
- {
- Ty *ptr = uninitialised_create<Ty>();
- construct(ptr, boost::is_pod<Ty>());
- return *ptr;
- }
-
- template <class Ty, class A0>
- Ty &create(A0 a0)
- {
- Ty *ptr = uninitialised_create<Ty>();
- new (ptr) Ty(a0);
- return *ptr;
- }
-
- template <class Ty, class A0, class A1>
- Ty &create(A0 a0, A1 a1)
- {
- Ty *ptr = uninitialised_create<Ty>();
- new (ptr) Ty(a0, a1);
- return *ptr;
- }
-
- template <class Ty>
- void destroy(Ty &object)
- {
- object.~Ty();
- }
-
- template <class Ty>
- void destroy(Ty const &object)
- {
- destroy(const_cast<Ty &>(object));
- }
-
- template <size_t N>
- char *allocate_bytes()
- {
- return allocate_bytes(N, boost::aligned_storage<N>::alignment);
- }
-
- char *allocate_bytes(size_t num_bytes, size_t alignment = 1)
- {
- return reinterpret_cast<char *>(allocate(num_bytes, alignment));
- }
-
- };
-
- } // namespace monotonic
+ size_t get_num_allocs() const
+ {
+ return num_allocations;
+ }
+#endif
+ //-----------------------------------------------------------------
+
+
+ template <class Ty>
+ Ty *uninitialised_create()
+ {
+ return reinterpret_cast<Ty *>(allocate_bytes<sizeof(Ty)>());
+ }
+
+ template <class Ty>
+ void construct(Ty *ptr, const boost::true_type& /*is_pod*/)
+ {
+ // do nothing
+ }
+
+ template <class Ty>
+ void construct(Ty *ptr, const boost::false_type&)
+ {
+ new (ptr) Ty();
+ }
+
+ template <class Ty>
+ Ty &create()
+ {
+ Ty *ptr = uninitialised_create<Ty>();
+ construct(ptr, boost::is_pod<Ty>());
+ return *ptr;
+ }
+
+ template <class Ty, class A0>
+ Ty &create(A0 a0)
+ {
+ Ty *ptr = uninitialised_create<Ty>();
+ new (ptr) Ty(a0);
+ return *ptr;
+ }
+
+ template <class Ty, class A0, class A1>
+ Ty &create(A0 a0, A1 a1)
+ {
+ Ty *ptr = uninitialised_create<Ty>();
+ new (ptr) Ty(a0, a1);
+ return *ptr;
+ }
+
+ template <class Ty>
+ void destroy(Ty &object)
+ {
+ object.~Ty();
+ }
+
+ template <class Ty>
+ void destroy(Ty const &object)
+ {
+ destroy(const_cast<Ty &>(object));
+ }
+
+ template <size_t N>
+ char *allocate_bytes()
+ {
+ return allocate_bytes(N, boost::aligned_storage<N>::alignment);
+ }
+
+ char *allocate_bytes(size_t num_bytes, size_t alignment = 1)
+ {
+ return reinterpret_cast<char *>(allocate(num_bytes, alignment));
+ }
+
+ };
+
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/monotonic/forward_declarations.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/forward_declarations.hpp (original)
+++ sandbox/monotonic/boost/monotonic/forward_declarations.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -15,93 +15,105 @@
 
 namespace boost
 {
- namespace monotonic
- {
+ namespace monotonic
+ {
 
- /// fixed-sized storage for an allocator that is on the stack or heap
- template <size_t InlineSize = DefaultSizes::InlineSize>
- struct fixed_storage;
-
- /// storage that can span the stack/heap boundary.
- ///
- /// allocation requests first use inline fixed_storage of InlineSize bytes.
- /// once that is exhausted, later requests are serviced from the heap.
- ///
- /// all allocations remain valid until the storage goes out of scope.
- template <
- size_t InlineSize = DefaultSizes::InlineSize
- , size_t MinHeapIncrement = DefaultSizes::MinHeapIncrement
- , class Al = default_allocator >
- struct storage;
-
- /// tags for different storage regions
- struct default_region_tag { };
- struct heap_region_tag { };
-
- /// tags for different access types
- struct default_access_tag { };
- struct shared_access_tag { };
- struct thread_local_access_tag { };
-
- /// selector to create a storage type given accessor
- namespace detail
- {
- template <class Region, class Access>
- struct storage_type;
- }
-
- /// a RIIA structure for accessing and releasing storage
- template <class Region = default_region_tag, class Access = default_access_tag>
- struct local;
-
- /// conventional, reclaimable storage
- template <size_t InlineSize = 0, size_t MinHeapIncrement = 0, class Al = default_allocator>
- struct reclaimable_storage;
-
- /// thread-safe storage
- //template <size_t InlineSize = DefaultSizes::InlineSize
- // , size_t MinHeapIncrement = DefaultSizes::MinHeapIncrement
- // , class Al = default_allocator>
- template <class Storage>
- struct shared_storage;
-
- /// thread-local storage
- template <size_t InlineSize = DefaultSizes::InlineSize
- , size_t MinHeapIncrement = DefaultSizes::MinHeapIncrement
- , class Al = default_allocator >
- struct thread_local_storage;
-
- /// a globally available storage buffer
- template <class Region = default_region_tag
- , class Access = default_access_tag
- , size_t InlineSize = DefaultSizes::/*Static*/InlineSize
- , size_t MinHeapIncrement = DefaultSizes::/*Static*/MinHeapIncrement
- , class Al = default_allocator >
- struct static_storage;
-
- /// common to other monotonic allocators for type T of type Derived
- template <class T, class Derived>
- struct allocator_base;
-
- /// a monotonic allocator has a storage buffer and a no-op deallocate() method
- ///
- /// each region uses independent storage
- ///
- /// each region is also factored over which access to use: global, shared, or thread-local storage
- template <class T, class Region = default_region_tag, class Access = default_access_tag>
- struct allocator;
-
- /// a monotonic shared_allocator has a shared storage buffer and a no-op deallocate() method
- /// defaults to use static_storage_base<..., shared_storage>
- template <class T, class Region = default_region_tag>
- struct shared_allocator;
-
- /// a monotonic local_allocator has a shared storage buffer and a no-op deallocate() method
- /// defaults to use static_storage_base<..., thread_local_storage>
- template <class T, class Region = default_region_tag>
- struct thread_local_allocator;
+ /// fixed-sized storage for an allocator that is on the stack or heap
+ template <size_t InlineSize = DefaultSizes::InlineSize>
+ struct fixed_storage;
+
+ /// storage that can span the stack/heap boundary.
+ ///
+ /// allocation requests first use inline fixed_storage of InlineSize bytes.
+ /// once that is exhausted, later requests are serviced from the heap.
+ ///
+ /// all allocations remain valid until the storage goes out of scope.
+ template <
+ size_t InlineSize = DefaultSizes::InlineSize
+ , size_t MinHeapIncrement = DefaultSizes::MinHeapIncrement
+ , class Al = default_allocator >
+ struct storage;
+
+ /// a fixed-size general stack
+ template <
+ size_t InlineSize = DefaultSizes::InlineSize>
+ struct fixed_stack;
+
+ /// a growable stack-like object that starts on the stack and can grow to the heap
+ template <
+ size_t InlineSize = DefaultSizes::InlineSize
+ , size_t MinHeapIncrement = DefaultSizes::MinHeapIncrement
+ , class Al = default_allocator >
+ struct stack;
+
+ /// tags for different storage regions
+ struct default_region_tag { };
+ struct heap_region_tag { };
+
+ /// tags for different access types
+ struct default_access_tag { };
+ struct shared_access_tag { };
+ struct thread_local_access_tag { };
+
+ /// selector to create a storage type given accessor
+ namespace detail
+ {
+ template <class Region, class Access>
+ struct storage_type;
+ }
+
+ /// a RIIA structure for accessing and releasing storage
+ template <class Region = default_region_tag, class Access = default_access_tag>
+ struct local;
+
+ /// conventional, reclaimable storage
+ template <size_t InlineSize = 0, size_t MinHeapIncrement = 0, class Al = default_allocator>
+ struct reclaimable_storage;
+
+ /// thread-safe storage
+ //template <size_t InlineSize = DefaultSizes::InlineSize
+ // , size_t MinHeapIncrement = DefaultSizes::MinHeapIncrement
+ // , class Al = default_allocator>
+ template <class Storage>
+ struct shared_storage;
+
+ /// thread-local storage
+ template <size_t InlineSize = DefaultSizes::InlineSize
+ , size_t MinHeapIncrement = DefaultSizes::MinHeapIncrement
+ , class Al = default_allocator >
+ struct thread_local_storage;
+
+ /// a globally available storage buffer
+ template <class Region = default_region_tag
+ , class Access = default_access_tag
+ , size_t InlineSize = DefaultSizes::/*Static*/InlineSize
+ , size_t MinHeapIncrement = DefaultSizes::/*Static*/MinHeapIncrement
+ , class Al = default_allocator >
+ struct static_storage;
+
+ /// common to other monotonic allocators for type T of type Derived
+ template <class T, class Derived>
+ struct allocator_base;
+
+ /// a monotonic allocator has a storage buffer and a no-op deallocate() method
+ ///
+ /// each region uses independent storage
+ ///
+ /// each region is also factored over which access to use: global, shared, or thread-local storage
+ template <class T, class Region = default_region_tag, class Access = default_access_tag>
+ struct allocator;
+
+ /// a monotonic shared_allocator has a shared storage buffer and a no-op deallocate() method
+ /// defaults to use static_storage_base<..., shared_storage>
+ template <class T, class Region = default_region_tag>
+ struct shared_allocator;
+
+ /// a monotonic local_allocator has a shared storage buffer and a no-op deallocate() method
+ /// defaults to use static_storage_base<..., thread_local_storage>
+ template <class T, class Region = default_region_tag>
+ struct thread_local_allocator;
 
- } // namespace monotonic
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/monotonic/local.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/local.hpp (original)
+++ sandbox/monotonic/boost/monotonic/local.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -12,88 +12,88 @@
 
 namespace boost
 {
- namespace monotonic
- {
- /// RIIA for storage
- template <class Region, class Access>
- struct local
- {
- typedef local<Region, Access> This;
-
- /// the storage to use
- typedef static_storage<
- Region
- , Access
- , DefaultSizes::InlineSize
- , DefaultSizes::MinHeapIncrement
- , default_allocator > StaticStorage;
-
- /// create a rebounded allocator type
- template <class T>
- struct allocator
- {
- typedef monotonic::allocator<T, Region, Access> type;
- };
-
- local()
- {
- }
- ~local()
- {
- reset();
- }
-
- template <class T>
- static monotonic::allocator<T,Region,Access> make_allocator()
- {
- return monotonic::allocator<T,Region,Access>();
- }
-
- static typename StaticStorage::StorageType &get_storage()
- {
- return StaticStorage::get_storage();
- }
- static void reset()
- {
- get_storage().reset();
- }
- static void release()
- {
- get_storage().release();
- }
-
- template <class Ty>
- Ty &create()
- {
- return get_storage().create<Ty>();
- }
- template <class Ty>
- Ty &create(Ty const &X)
- {
- return get_storage().create<Ty>(X);
- }
- template <class Ty>
- void destroy(Ty &X)
- {
- get_storage().destroy(X);
- }
-
- static size_t fixed_used()
- {
- return get_storage().fixed_used();
- }
- static size_t heap_used()
- {
- return get_storage().heap_used();
- }
- static size_t used()
- {
- return get_storage().used();
- }
+ namespace monotonic
+ {
+ /// RIIA for storage
+ template <class Region, class Access>
+ struct local
+ {
+ typedef local<Region, Access> This;
+
+ /// the storage to use
+ typedef static_storage<
+ Region
+ , Access
+ , DefaultSizes::InlineSize
+ , DefaultSizes::MinHeapIncrement
+ , default_allocator > StaticStorage;
+
+ /// create a rebounded allocator type
+ template <class T>
+ struct allocator
+ {
+ typedef monotonic::allocator<T, Region, Access> type;
+ };
+
+ local()
+ {
+ }
+ ~local()
+ {
+ reset();
+ }
+
+ template <class T>
+ static monotonic::allocator<T,Region,Access> make_allocator()
+ {
+ return monotonic::allocator<T,Region,Access>();
+ }
+
+ static typename StaticStorage::StorageType &get_storage()
+ {
+ return StaticStorage::get_storage();
+ }
+ static void reset()
+ {
+ get_storage().reset();
+ }
+ static void release()
+ {
+ get_storage().release();
+ }
+
+ template <class Ty>
+ Ty &create()
+ {
+ return get_storage().create<Ty>();
+ }
+ template <class Ty>
+ Ty &create(Ty const &X)
+ {
+ return get_storage().create<Ty>(X);
+ }
+ template <class Ty>
+ void destroy(Ty &X)
+ {
+ get_storage().destroy(X);
+ }
+
+ static size_t fixed_used()
+ {
+ return get_storage().fixed_used();
+ }
+ static size_t heap_used()
+ {
+ return get_storage().heap_used();
+ }
+ static size_t used()
+ {
+ return get_storage().used();
+ }
 
- };
+ };
 
- } // namespace monotonic
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/monotonic/monotonic.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/monotonic.hpp (original)
+++ sandbox/monotonic/boost/monotonic/monotonic.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -9,8 +9,8 @@
 #include <boost/monotonic/detail/prefix.hpp>
 
 #ifdef BOOST_MONOTONIC_THREADS
-# include <boost/monotonic/shared_allocator.hpp>
-//TODO # include <boost/monotonic/thread_local_allocator.hpp>
+# include <boost/monotonic/shared_allocator.hpp>
+//TODO # include <boost/monotonic/thread_local_allocator.hpp>
 #endif
 
 #include <boost/monotonic/containers/string.hpp>
@@ -23,10 +23,10 @@
 
 namespace boost
 {
- namespace monotonic
- {
+ namespace monotonic
+ {
 
- } // namespace monotonic
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/monotonic/reclaimable_storage.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/reclaimable_storage.hpp (original)
+++ sandbox/monotonic/boost/monotonic/reclaimable_storage.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -16,201 +16,201 @@
 
 namespace boost
 {
- namespace monotonic
- {
- namespace detail
- {
- template <>
- struct storage_type<heap_region_tag, default_access_tag>
- {
- template <size_t N, size_t M, class Al>
- struct storage
- {
- typedef reclaimable_storage<N,M,Al> type;
- };
- };
-
- }
-
- /// conventional, reclaimable storage
- ///
- /// this is really a long way around to using new and delete, however it
- /// also keeps track of the allocations made so they can be released.
- template <size_t InlineSize, size_t MinHeapIncrement, class Al>
- struct reclaimable_storage : storage_base
- {
- typedef reclaimable_storage<InlineSize, MinHeapIncrement, Al> This;
- typedef Al Allocator;
- typedef typename Allocator::template rebind<char>::other CharAllocator;
-
- /* this has to go to an allocator
- struct AllocationBase
- {
- void *ptr;
- AllocationBase(void *P = 0) : ptr(P) { }
- virtual void destroy() = 0;
- };
- template <class T>
- struct Allocation : AllocationBase
- {
- Allocation(T *P) : AllocationBase(P) { }
- void destroy()
- {
- static_cast<T *>(this->AllocationBase::ptr)->~T();
- }
- };
- template <class T, class Alloc>
- static Allocation<T> MakeAllocation(T *ptr, Alloc al)
- {
- typename Alloc::template rebind<Allocation<T> >::other(al) allocator;
- Allocation<T> *allocation = allocator.allocate(1);
- allocator.construct(allocation, ptr);
- return allocation;
- }*/
-
- /* this has to go to a tracking_allocator
- struct Allocation
- {
- void *ptr;
- size_t size;
- Allocation(void *P = 0, size_t N = 0) : ptr(P), size(N) { }
- void *get_pointer() const { return ptr; }
- size_t get_size() const { return size; }
- };
- struct AllocHash
- {
- size_t operator()(Allocation const &alloc) const
- {
- return reinterpret_cast<size_t>(alloc.ptr);
- }
- };
- struct AllocLess
- {
- bool operator()(Allocation const &A, Allocation const &B) const
- {
- return A.ptr < B.ptr;
- }
- };
- typedef boost::unordered_set<
- Allocation
- , AllocHash
- , AllocLess
- , Allocator>
- Allocations;
- */
-
- private:
- CharAllocator alloc;
-
- public:
- reclaimable_storage()
- {
- }
- reclaimable_storage(Allocator const &A)
- : alloc(A)
- {
- }
- ~reclaimable_storage()
- {
- release();
- }
-
- void reset()
- {
- }
-
- void release()
- {
- }
-
- void *allocate(size_t num_bytes, size_t /*alignment*/ = 1)
- {
- return alloc.allocate(num_bytes);
- }
-
- void deallocate(void *ptr)
- {
- alloc.deallocate((char *)ptr, 1);
- }
-
- size_t max_size() const
- {
- return (std::numeric_limits<size_t>::max)();
- }
-
- size_t remaining() const
- {
- return max_size();
- }
-
- size_t used() const
- {
- BOOST_ASSERT(0);
- return 0;
- }
-
- // ------------------------------------------------------------------------
-
- template <class Ty>
- Ty *uninitialised_create()
- {
- return reinterpret_cast<Ty *>(allocate_bytes<sizeof(Ty)>());
- }
-
- template <class Ty>
- Ty &create()
- {
- Ty *ptr = uninitialised_create<Ty>();
- construct(ptr, boost::is_pod<Ty>());
- return *ptr;
- }
-
- template <class Ty>
- void construct(Ty *ptr, const boost::true_type& /*is_pod*/)
- {
- // do nothing
- }
-
- template <class Ty>
- void construct(Ty *ptr, const boost::false_type&)
- {
- new (ptr) Ty();
- }
-
- template <class Ty>
- Ty &create(Ty const &X)
- {
- Ty *ptr = uninitialised_create<Ty>();
- new (ptr) Ty(X);
- return *ptr;
- }
-
- template <class Ty>
- void destroy(Ty &object)
- {
- object.~Ty();
- deallocate(&object, 1);
- }
-
- template <class Ty>
- void destroy(Ty const &object)
- {
- destroy(const_cast<Ty &>(object));
- }
-
- template <size_t N>
- char *allocate_bytes()
- {
- return allocate_bytes(N, boost::aligned_storage<N>::alignment);
- }
-
- char *allocate_bytes(size_t num_bytes, size_t alignment = 1)
- {
- return reinterpret_cast<char *>(allocate(num_bytes, alignment));
- }
- };
+ namespace monotonic
+ {
+ namespace detail
+ {
+ template <>
+ struct storage_type<heap_region_tag, default_access_tag>
+ {
+ template <size_t N, size_t M, class Al>
+ struct storage
+ {
+ typedef reclaimable_storage<N,M,Al> type;
+ };
+ };
+
+ }
+
+ /// conventional, reclaimable storage
+ ///
+ /// this is really a long way around to using new and delete, however it
+ /// also keeps track of the allocations made so they can be released.
+ template <size_t InlineSize, size_t MinHeapIncrement, class Al>
+ struct reclaimable_storage : storage_base
+ {
+ typedef reclaimable_storage<InlineSize, MinHeapIncrement, Al> This;
+ typedef Al Allocator;
+ typedef typename Allocator::template rebind<char>::other CharAllocator;
+
+ /* this has to go to an allocator
+ struct AllocationBase
+ {
+ void *ptr;
+ AllocationBase(void *P = 0) : ptr(P) { }
+ virtual void destroy() = 0;
+ };
+ template <class T>
+ struct Allocation : AllocationBase
+ {
+ Allocation(T *P) : AllocationBase(P) { }
+ void destroy()
+ {
+ static_cast<T *>(this->AllocationBase::ptr)->~T();
+ }
+ };
+ template <class T, class Alloc>
+ static Allocation<T> MakeAllocation(T *ptr, Alloc al)
+ {
+ typename Alloc::template rebind<Allocation<T> >::other(al) allocator;
+ Allocation<T> *allocation = allocator.allocate(1);
+ allocator.construct(allocation, ptr);
+ return allocation;
+ }*/
+
+ /* this has to go to a tracking_allocator
+ struct Allocation
+ {
+ void *ptr;
+ size_t size;
+ Allocation(void *P = 0, size_t N = 0) : ptr(P), size(N) { }
+ void *get_pointer() const { return ptr; }
+ size_t get_size() const { return size; }
+ };
+ struct AllocHash
+ {
+ size_t operator()(Allocation const &alloc) const
+ {
+ return reinterpret_cast<size_t>(alloc.ptr);
+ }
+ };
+ struct AllocLess
+ {
+ bool operator()(Allocation const &A, Allocation const &B) const
+ {
+ return A.ptr < B.ptr;
+ }
+ };
+ typedef boost::unordered_set<
+ Allocation
+ , AllocHash
+ , AllocLess
+ , Allocator>
+ Allocations;
+ */
+
+ private:
+ CharAllocator alloc;
+
+ public:
+ reclaimable_storage()
+ {
+ }
+ reclaimable_storage(Allocator const &A)
+ : alloc(A)
+ {
+ }
+ ~reclaimable_storage()
+ {
+ release();
+ }
+
+ void reset()
+ {
+ }
+
+ void release()
+ {
+ }
+
+ void *allocate(size_t num_bytes, size_t /*alignment*/ = 1)
+ {
+ return alloc.allocate(num_bytes);
+ }
+
+ void deallocate(void *ptr)
+ {
+ alloc.deallocate((char *)ptr, 1);
+ }
+
+ size_t max_size() const
+ {
+ return (std::numeric_limits<size_t>::max)();
+ }
+
+ size_t remaining() const
+ {
+ return max_size();
+ }
+
+ size_t used() const
+ {
+ BOOST_ASSERT(0);
+ return 0;
+ }
+
+ // ------------------------------------------------------------------------
+
+ template <class Ty>
+ Ty *uninitialised_create()
+ {
+ return reinterpret_cast<Ty *>(allocate_bytes<sizeof(Ty)>());
+ }
+
+ template <class Ty>
+ Ty &create()
+ {
+ Ty *ptr = uninitialised_create<Ty>();
+ construct(ptr, boost::is_pod<Ty>());
+ return *ptr;
+ }
+
+ template <class Ty>
+ void construct(Ty *ptr, const boost::true_type& /*is_pod*/)
+ {
+ // do nothing
+ }
+
+ template <class Ty>
+ void construct(Ty *ptr, const boost::false_type&)
+ {
+ new (ptr) Ty();
+ }
+
+ template <class Ty>
+ Ty &create(Ty const &X)
+ {
+ Ty *ptr = uninitialised_create<Ty>();
+ new (ptr) Ty(X);
+ return *ptr;
+ }
+
+ template <class Ty>
+ void destroy(Ty &object)
+ {
+ object.~Ty();
+ deallocate(&object, 1);
+ }
+
+ template <class Ty>
+ void destroy(Ty const &object)
+ {
+ destroy(const_cast<Ty &>(object));
+ }
+
+ template <size_t N>
+ char *allocate_bytes()
+ {
+ return allocate_bytes(N, boost::aligned_storage<N>::alignment);
+ }
+
+ char *allocate_bytes(size_t num_bytes, size_t alignment = 1)
+ {
+ return reinterpret_cast<char *>(allocate(num_bytes, alignment));
+ }
+ };
 
- } // namespace monotonic
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/monotonic/shared_allocator.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/shared_allocator.hpp (original)
+++ sandbox/monotonic/boost/monotonic/shared_allocator.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -11,67 +11,67 @@
 
 namespace boost
 {
- namespace monotonic
- {
- template <class Region>
- struct shared_allocator<void, Region>
- {
- typedef void* pointer;
- typedef const void* const_pointer;
-
- typedef void value_type;
- template <class U>
- struct rebind
- {
- typedef shared_allocator<U, Region> other;
- };
- };
-
- template <class T, class Region>
- struct shared_allocator : allocator<T, Region, shared_access_tag>
- {
- typedef allocator<T, Region, shared_access_tag> Parent;
- using typename Parent::size_type;
- using typename Parent::difference_type;
- using typename Parent::pointer;
- using typename Parent::const_pointer;
- using typename Parent::reference;
- using typename Parent::const_reference;
- using typename Parent::value_type;
-
- template <class U>
- struct rebind
- {
- typedef shared_allocator<U, Region> other;
- };
-
- shared_allocator() throw()
- : Parent(boost::monotonic::static_storage<Region,shared_access_tag>::get_storage()) { }
-
- public:
- shared_allocator(storage_base &store) throw()
- : Parent(store) { }
-
- public:
- shared_allocator(const shared_allocator& alloc) throw()
- : Parent(alloc) { }
-
- template <class U>
- shared_allocator(const shared_allocator<U, Region> &alloc) throw()
- : Parent(alloc) { }
-
- friend bool operator==(shared_allocator<T,Region> const &A, shared_allocator<T,Region> const &B)
- {
- return static_cast<Parent const &>(A) == static_cast<Parent const &>(B);
- }
-
- friend bool operator!=(shared_allocator<T,Region> const &A, shared_allocator<T,Region> const &B)
- {
- return static_cast<Parent const &>(A) != static_cast<Parent const &>(B);
- }
- };
+ namespace monotonic
+ {
+ template <class Region>
+ struct shared_allocator<void, Region>
+ {
+ typedef void* pointer;
+ typedef const void* const_pointer;
+
+ typedef void value_type;
+ template <class U>
+ struct rebind
+ {
+ typedef shared_allocator<U, Region> other;
+ };
+ };
+
+ template <class T, class Region>
+ struct shared_allocator : allocator<T, Region, shared_access_tag>
+ {
+ typedef allocator<T, Region, shared_access_tag> Parent;
+ using typename Parent::size_type;
+ using typename Parent::difference_type;
+ using typename Parent::pointer;
+ using typename Parent::const_pointer;
+ using typename Parent::reference;
+ using typename Parent::const_reference;
+ using typename Parent::value_type;
+
+ template <class U>
+ struct rebind
+ {
+ typedef shared_allocator<U, Region> other;
+ };
+
+ shared_allocator() throw()
+ : Parent(boost::monotonic::static_storage<Region,shared_access_tag>::get_storage()) { }
+
+ public:
+ shared_allocator(storage_base &store) throw()
+ : Parent(store) { }
+
+ public:
+ shared_allocator(const shared_allocator& alloc) throw()
+ : Parent(alloc) { }
+
+ template <class U>
+ shared_allocator(const shared_allocator<U, Region> &alloc) throw()
+ : Parent(alloc) { }
+
+ friend bool operator==(shared_allocator<T,Region> const &A, shared_allocator<T,Region> const &B)
+ {
+ return static_cast<Parent const &>(A) == static_cast<Parent const &>(B);
+ }
+
+ friend bool operator!=(shared_allocator<T,Region> const &A, shared_allocator<T,Region> const &B)
+ {
+ return static_cast<Parent const &>(A) != static_cast<Parent const &>(B);
+ }
+ };
 
- } // namespace monotonic
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/monotonic/shared_storage.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/shared_storage.hpp (original)
+++ sandbox/monotonic/boost/monotonic/shared_storage.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -12,82 +12,82 @@
 
 namespace boost
 {
- namespace monotonic
- {
- namespace detail
- {
- template <class Region>
- struct storage_type<Region,shared_access_tag>
- {
- template <size_t N, size_t M, class Al>
- struct storage
- {
- typedef shared_storage<storage<N,M,Al> > type;
- };
- };
- }
-
- /// thread-safe storage
- template <class Storage>
- struct shared_storage : storage_base
- {
- private:
- Storage store;
- mutable mutex guard;
-
- public:
- shared_storage()
- {
- }
- template <class Allocator>
- shared_storage(Allocator A)
- : store(A)
- {
- }
- size_t used() const
- {
- mutex::scoped_lock lock(guard);
- return store.used();
- }
- void reset()
- {
- mutex::scoped_lock lock(guard);
- store.reset();
- }
- void release()
- {
- mutex::scoped_lock lock(guard);
- store.release();
- }
- void *allocate(size_t num_bytes, size_t alignment)
- {
- mutex::scoped_lock lock(guard);
- return store.allocate(num_bytes, alignment);
- }
- void deallocate(void *ptr)
- {
- mutex::scoped_lock lock(guard);
- store.deallocate(ptr);
- }
- size_t remaining() const
- {
- mutex::scoped_lock lock(guard);
- return store.remaining();
- }
- size_t fixed_remaining() const
- {
- mutex::scoped_lock lock(guard);
- return store.fixed_remaining();
- }
- size_t max_size() const
- {
- mutex::scoped_lock lock(guard);
- return store.max_size();
- }
+ namespace monotonic
+ {
+ namespace detail
+ {
+ template <class Region>
+ struct storage_type<Region,shared_access_tag>
+ {
+ template <size_t N, size_t M, class Al>
+ struct storage
+ {
+ typedef shared_storage<storage<N,M,Al> > type;
+ };
+ };
+ }
+
+ /// thread-safe storage
+ template <class Storage>
+ struct shared_storage : storage_base
+ {
+ private:
+ Storage store;
+ mutable mutex guard;
+
+ public:
+ shared_storage()
+ {
+ }
+ template <class Allocator>
+ shared_storage(Allocator A)
+ : store(A)
+ {
+ }
+ size_t used() const
+ {
+ mutex::scoped_lock lock(guard);
+ return store.used();
+ }
+ void reset()
+ {
+ mutex::scoped_lock lock(guard);
+ store.reset();
+ }
+ void release()
+ {
+ mutex::scoped_lock lock(guard);
+ store.release();
+ }
+ void *allocate(size_t num_bytes, size_t alignment)
+ {
+ mutex::scoped_lock lock(guard);
+ return store.allocate(num_bytes, alignment);
+ }
+ void deallocate(void *ptr)
+ {
+ mutex::scoped_lock lock(guard);
+ store.deallocate(ptr);
+ }
+ size_t remaining() const
+ {
+ mutex::scoped_lock lock(guard);
+ return store.remaining();
+ }
+ size_t fixed_remaining() const
+ {
+ mutex::scoped_lock lock(guard);
+ return store.fixed_remaining();
+ }
+ size_t max_size() const
+ {
+ mutex::scoped_lock lock(guard);
+ return store.max_size();
+ }
 
- };
+ };
 
- } // namespace monotonic
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/monotonic/stack.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/stack.hpp (original)
+++ sandbox/monotonic/boost/monotonic/stack.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -19,303 +19,322 @@
 
 namespace boost
 {
- namespace monotonic
- {
- struct null_pointer {};
-
- /// a first-class stack object
- template <size_t InlineSize = DefaultSizes::InlineSize>
- struct stack
- {
- typedef stack<InlineSize> this_type;
-
- private:
- fixed_storage<InlineSize> store;
-
- template <class>
- struct element;
-
- /// an entry on the stack
- struct element_base
- {
- element_base *previous;
- size_t cursor;
- bool is_pod;
- element_base(bool ip = false)
- : is_pod(ip) { }
- template <class T>
- bool is_type() const
- {
- return get_type() == typeid(T);
- }
- template <class T>
- T &get()
- {
- if (get_type() != typeid(T))
- throw std::bad_get();
- return *static_get<element<T> &>(*this).get_pointer();
- }
- template <class T>
- const T &get() const
- {
- if (get_type() != typeid(T))
- throw std::bad_get();
- return *static_get<const element<T> &>(*this).get_pointer();
- }
- virtual void destroy() {}
- virtual const std::type_info &get_type() const = 0;
- };
- struct impl
- {
- /// a class-type element
- template <class T, bool>
- struct element : element_base
- {
- typedef T type;
- typedef type *pointer;
-
- private:
- pointer ptr;
- char value[sizeof(T)];
-
- public:
- element()
- : ptr(reinterpret_cast<T *>(value))
- {
- }
- const std::type_info &get_type() const
- {
- return typeid(T);
- }
- pointer get_pointer()
- {
- return ptr;
- }
- void destroy()
- {
- destroy(ptr, boost::has_trivial_destructor<type>());
- }
- void destroy(pointer ptr, const boost::false_type& )
- {
- (*ptr).~type();
- }
-
- void destroy(pointer, const boost::true_type& )
- {
- }
- };
-
- /// a pod-type element
- template <class T>
- struct element<T, true> : element_base
- {
- typedef T type;
- type val;
- element()
- : element_base(true)
- {
- }
- type *get_pointer()
- {
- return &val;
- }
- const std::type_info &get_type() const
- {
- return typeid(T);
- }
- };
- };
-
- /// an element of a given type on the stack
- template <class T>
- struct element
- : impl::element<T, boost::is_pod<T>::value>
- {
- };
-
- element_base *previous;
-
- public:
- typedef element_base value_type;
- typedef element_base &reference;
- typedef element_base const &const_reference;
- typedef size_t size_type;
-
- struct const_iterator : boost::iterator<forward_traversal_tag, element_base>
- {
- typedef element_base value_type;
- element_base *current;
-
- const_iterator(element_base *elem = 0)
- : current(elem) { }
-
- const value_type &operator*() const
- {
- return *current;
- }
- const value_type *operator->() const
- {
- return current;
- }
- const_iterator &operator++()
- {
- current = current->previous;
- return *this;
- }
- const_iterator operator++(int)
- {
- const_iterator tmp = *this;
- ++(*this);
- return tmp;
- }
- friend bool operator==(const_iterator left, const_iterator right)
- {
- return left.current == right.current;
- }
- friend bool operator!=(const_iterator left, const_iterator right)
- {
- return left.current != right.current;
- }
- };
-
- struct iterator : const_iterator
- {
- iterator(element_base *elem = 0)
- : const_iterator(elem) { }
-
- value_type &operator*()
- {
- return *current;
- }
- value_type *operator->()
- {
- return current;
- }
- iterator &operator++()
- {
- const_iterator::operator++(0);
- return *this;
- }
- iterator operator++(int)
- {
- iterator tmp = *this;
- const_iterator::operator++(0);
- return tmp;
- }
- friend bool operator==(iterator left, iterator right)
- {
- return left.current == right.current;
- }
- friend bool operator!=(iterator left, iterator right)
- {
- return left.current != right.current;
- }
- };
-
- public:
- stack()
- : previous(0)
- {
- }
- ~stack()
- {
- clear();
- }
-
- size_t size() const
- {
- size_t len = 0;
- const_iterator F = begin(), L = end();
- for (; F != L; ++F)
- ++len;
- return len;
- }
- const_iterator begin() const
- {
- return const_iterator(previous);
- }
- const_iterator end() const
- {
- return const_iterator(0);
- }
- iterator begin()
- {
- return iterator(previous);
- }
- iterator end()
- {
- return iterator(0);
- }
-
- template <class T>
- T &push()
- {
- element<T> &elem = push_element<T>();
- if (!is_pod<T>::value)
- new (elem.get_pointer()) T();
- return *elem.get_pointer();
- }
-
- template <class T, class A0>
- T &push(A0 a0)
- {
- element<T> &elem = push_element<T>();
- new (elem.get_pointer()) T(a0);
- return *elem.get_pointer();
- }
-
- template <class T, class A0, class A1>
- T &push(A0 a0, A1 a1)
- {
- element<T> &elem = push_element<T>();
- new (elem.get_pointer()) T(a0, a1);
- return *elem.get_pointer();
- }
-
- template <class T, size_t N>
- array<T, N> &push_array()
- {
- return push<array<T, N> >();
- }
-
- void pop()
- {
- BOOST_ASSERT(previous);
- element_base *elem = previous;
- previous = elem->previous;
- size_t cursor = elem->cursor;
- if (!elem->is_pod) // avoid empty virtual call for pods
- elem->destroy();
- store.set_cursor(cursor);
- }
-
- size_t top() const
- {
- return store.get_cursor();
- }
-
- void clear()
- {
- while (previous != 0)
- {
- pop();
- }
- }
-
- private:
- template <class T>
- element<T> &push_element()
- {
- size_t cursor = store.get_cursor();
- element<T> &elem = store.create<element<T> >();
- elem.previous = previous;
- elem.cursor = cursor;
- previous = &elem;
- return elem;
- }
- };
- }
-}
+ namespace monotonic
+ {
+ struct null_pointer {};
+
+ /// a first-class stack object
+ template <size_t InlineSize>
+ struct fixed_stack
+ {
+ typedef fixed_stack<InlineSize> this_type;
+
+ private:
+ fixed_storage<InlineSize> store;
+
+ template <class>
+ struct element;
+
+ /// an entry on the stack
+ struct element_base
+ {
+ element_base *previous;
+ size_t cursor;
+ bool is_pod;
+ element_base(bool ip = false)
+ : is_pod(ip) { }
+ template <class T>
+ bool is_type() const
+ {
+ return get_type() == typeid(T);
+ }
+ template <class T>
+ T &get()
+ {
+ if (get_type() != typeid(T))
+ throw std::bad_get();
+ return *static_get<element<T> &>(*this).get_pointer();
+ }
+ template <class T>
+ const T &get() const
+ {
+ if (get_type() != typeid(T))
+ throw std::bad_get();
+ return *static_get<const element<T> &>(*this).get_pointer();
+ }
+
+ virtual void destroy() {}
+ virtual const std::type_info &get_type() const = 0;
+ };
+ struct impl
+ {
+ /// a class-type element
+ template <class T, bool>
+ struct element : element_base
+ {
+ typedef T type;
+ typedef type *pointer;
+
+ private:
+ pointer ptr;
+ char value[sizeof(T)];
+
+ public:
+ element()
+ : ptr(reinterpret_cast<T *>(value))
+ {
+ }
+ const std::type_info &get_type() const
+ {
+ return typeid(T);
+ }
+ pointer get_pointer()
+ {
+ return ptr;
+ }
+ void destroy()
+ {
+ destroy(ptr, boost::has_trivial_destructor<type>());
+ }
+ void destroy(pointer ptr, const boost::false_type& )
+ {
+ (*ptr).~type();
+ }
+
+ void destroy(pointer, const boost::true_type& )
+ {
+ }
+ };
+
+ /// a pod-type element
+ template <class T>
+ struct element<T, true> : element_base
+ {
+ typedef T type;
+ type val;
+ element()
+ : element_base(true)
+ {
+ }
+ type *get_pointer()
+ {
+ return &val;
+ }
+ const std::type_info &get_type() const
+ {
+ return typeid(T);
+ }
+ };
+ };
+
+ /// an element of a given type on the stack
+ template <class T>
+ struct element
+ : impl::element<T, boost::is_pod<T>::value>
+ {
+ };
+
+ element_base *previous;
+
+ public:
+ typedef element_base value_type;
+ typedef element_base &reference;
+ typedef element_base const &const_reference;
+ typedef size_t size_type;
+
+ struct const_iterator : boost::iterator<forward_traversal_tag, element_base>
+ {
+ typedef element_base value_type;
+ element_base *current;
+
+ const_iterator(element_base *elem = 0)
+ : current(elem) { }
+
+ const value_type &operator*() const
+ {
+ return *current;
+ }
+ const value_type *operator->() const
+ {
+ return current;
+ }
+ const_iterator &operator++()
+ {
+ current = current->previous;
+ return *this;
+ }
+ const_iterator operator++(int)
+ {
+ const_iterator tmp = *this;
+ ++(*this);
+ return tmp;
+ }
+ friend bool operator==(const_iterator left, const_iterator right)
+ {
+ return left.current == right.current;
+ }
+ friend bool operator!=(const_iterator left, const_iterator right)
+ {
+ return left.current != right.current;
+ }
+ };
+
+ struct iterator : const_iterator
+ {
+ iterator(element_base *elem = 0)
+ : const_iterator(elem) { }
+
+ value_type &operator*()
+ {
+ return *current;
+ }
+ value_type *operator->()
+ {
+ return current;
+ }
+ iterator &operator++()
+ {
+ const_iterator::operator++(0);
+ return *this;
+ }
+ iterator operator++(int)
+ {
+ iterator tmp = *this;
+ const_iterator::operator++(0);
+ return tmp;
+ }
+ };
+
+ public:
+ fixed_stack()
+ : previous(0)
+ {
+ }
+ ~fixed_stack()
+ {
+ clear();
+ }
+
+ size_t size() const
+ {
+ size_t len = 0;
+ const_iterator F = begin(), L = end();
+ for (; F != L; ++F)
+ ++len;
+ return len;
+ }
+ const_iterator begin() const
+ {
+ return const_iterator(previous);
+ }
+ const_iterator end() const
+ {
+ return const_iterator(0);
+ }
+ iterator begin()
+ {
+ return iterator(previous);
+ }
+ iterator end()
+ {
+ return iterator(0);
+ }
+
+ template <class T>
+ T &push()
+ {
+ element<T> &elem = push_element<T>();
+ if (!is_pod<T>::value)
+ new (elem.get_pointer()) T();
+ return *elem.get_pointer();
+ }
+
+ template <class T, class A0>
+ T &push(A0 a0)
+ {
+ element<T> &elem = push_element<T>();
+ new (elem.get_pointer()) T(a0);
+ return *elem.get_pointer();
+ }
+
+ template <class T, class A0, class A1>
+ T &push(A0 a0, A1 a1)
+ {
+ element<T> &elem = push_element<T>();
+ new (elem.get_pointer()) T(a0, a1);
+ return *elem.get_pointer();
+ }
+
+ template <class T, size_t N>
+ array<T, N> &push_array()
+ {
+ return push<array<T, N> >();
+ }
+
+ void pop()
+ {
+ BOOST_ASSERT(previous);
+ element_base *elem = previous;
+ previous = elem->previous;
+ size_t cursor = elem->cursor;
+ if (!elem->is_pod) // avoid empty virtual call for pods
+ elem->destroy();
+ store.set_cursor(cursor);
+ }
+
+ size_t top() const
+ {
+ return store.get_cursor();
+ }
+
+ void clear()
+ {
+ while (previous != 0)
+ {
+ pop();
+ }
+ }
+
+ private:
+ template <class T>
+ element<T> &push_element()
+ {
+ size_t cursor = store.get_cursor();
+ element<T> &elem = store.create<element<T> >();
+ elem.previous = previous;
+ elem.cursor = cursor;
+ previous = &elem;
+ return elem;
+ }
+ };
+
+ template <size_t Size, size_t Inc, class Al>
+ struct stack
+ {
+ fixed_stack<Size> fixed;
+
+ private:
+ storage<Size, Inc, Al> storage;
+
+ public:
+ stack()
+ {
+ }
+ ~stack()
+ {
+ clear();
+ }
+
+ template <class T>
+ T &push()
+ {
+
+ }
+ };
+
+ } // namespace monotonic
+
+} // namespace boost
 
 #include <boost/monotonic/detail/postfix.hpp>
 

Modified: sandbox/monotonic/boost/monotonic/static_storage.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/static_storage.hpp (original)
+++ sandbox/monotonic/boost/monotonic/static_storage.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -11,104 +11,104 @@
 
 namespace boost
 {
- namespace monotonic
- {
- namespace detail
- {
- template <class Region>
- struct storage_type<Region, default_access_tag>
- {
- template <size_t N, size_t M, class Al>
- struct storage
- {
- typedef monotonic::storage<N,M,Al> type;
- };
- };
- }
-
- template <class Region
- , class Access
- , size_t InlineSize
- , size_t MinHeapIncrement
- , class Al>
- struct static_storage
- {
- typedef Al HeapAllocator;
- typedef detail::storage_type<Region,Access> Selector;
- typedef typename Selector::template storage<InlineSize, MinHeapIncrement, HeapAllocator>::type StorageType;
-
- private:
- static StorageType global;
-
- public:
- static_storage()
- {
- }
- static StorageType &get_storage()
- {
- return global;
- }
- static void reset()
- {
- global.reset();
- }
- static void release()
- {
- global.release();
- }
- static void *allocate(size_t num_bytes, size_t alignment)
- {
- return global.allocate(num_bytes, alignment);
- }
- static size_t max_size()
- {
- return global.max_size();
- }
- static size_t used()
- {
- return global.used();
- }
- static size_t remaining()
- {
- return global.remaining();
- }
- };
-
- /// define the static storage member for all regions with all access types
- template <class Region
- , class Access
- , size_t InlineSize
- , size_t MinHeapIncrement
- , class Al>
- typename static_storage<Region, Access, InlineSize, MinHeapIncrement, Al>::StorageType
- static_storage<Region, Access, InlineSize, MinHeapIncrement, Al>::global;
-
- //template <class Region
- // , class Access = default_access_tag
- // , size_t N = DefaultSizes::InlineSize
- // , size_t M = DefaultSizes::MinHeapIncrement
- // , class Al = std::allocator<void> >
- //struct get_storage
- //{
- // typedef static_storage_base<Region,Access,N,M,Al> StaticStorage;
-
- // static typename StaticStorage::StorageType &get()
- // {
- // return StaticStorage::get_storage();
- // }
- //};
-
- inline void reset_storage()
- {
- static_storage<default_region_tag>::reset();
- }
-
- inline void release_storage()
- {
- static_storage<default_region_tag>::release();
- }
+ namespace monotonic
+ {
+ namespace detail
+ {
+ template <class Region>
+ struct storage_type<Region, default_access_tag>
+ {
+ template <size_t N, size_t M, class Al>
+ struct storage
+ {
+ typedef monotonic::storage<N,M,Al> type;
+ };
+ };
+ }
+
+ template <class Region
+ , class Access
+ , size_t InlineSize
+ , size_t MinHeapIncrement
+ , class Al>
+ struct static_storage
+ {
+ typedef Al HeapAllocator;
+ typedef detail::storage_type<Region,Access> Selector;
+ typedef typename Selector::template storage<InlineSize, MinHeapIncrement, HeapAllocator>::type StorageType;
+
+ private:
+ static StorageType global;
+
+ public:
+ static_storage()
+ {
+ }
+ static StorageType &get_storage()
+ {
+ return global;
+ }
+ static void reset()
+ {
+ global.reset();
+ }
+ static void release()
+ {
+ global.release();
+ }
+ static void *allocate(size_t num_bytes, size_t alignment)
+ {
+ return global.allocate(num_bytes, alignment);
+ }
+ static size_t max_size()
+ {
+ return global.max_size();
+ }
+ static size_t used()
+ {
+ return global.used();
+ }
+ static size_t remaining()
+ {
+ return global.remaining();
+ }
+ };
+
+ /// define the static storage member for all regions with all access types
+ template <class Region
+ , class Access
+ , size_t InlineSize
+ , size_t MinHeapIncrement
+ , class Al>
+ typename static_storage<Region, Access, InlineSize, MinHeapIncrement, Al>::StorageType
+ static_storage<Region, Access, InlineSize, MinHeapIncrement, Al>::global;
+
+ //template <class Region
+ // , class Access = default_access_tag
+ // , size_t N = DefaultSizes::InlineSize
+ // , size_t M = DefaultSizes::MinHeapIncrement
+ // , class Al = std::allocator<void> >
+ //struct get_storage
+ //{
+ // typedef static_storage_base<Region,Access,N,M,Al> StaticStorage;
+
+ // static typename StaticStorage::StorageType &get()
+ // {
+ // return StaticStorage::get_storage();
+ // }
+ //};
+
+ inline void reset_storage()
+ {
+ static_storage<default_region_tag>::reset();
+ }
+
+ inline void release_storage()
+ {
+ static_storage<default_region_tag>::release();
+ }
 
- } // namespace monotonic
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/monotonic/storage.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/storage.hpp (original)
+++ sandbox/monotonic/boost/monotonic/storage.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -14,254 +14,305 @@
 
 namespace boost
 {
- namespace monotonic
- {
- /// storage that spans the stack/heap boundary.
- ///
- /// allocation requests first use inline fixed_storage of InlineSize bytes.
- /// once that is exhausted, later requests are serviced from the heap.
- ///
- /// all allocations remain valid at all times.
- template <size_t InlineSize, size_t MinHeapIncrement, class Al>
- struct storage : storage_base
- {
- BOOST_STATIC_CONSTANT(size_t, NumPools = 8);
- BOOST_STATIC_CONSTANT(size_t, ChunkShift = 4);
- BOOST_STATIC_CONSTANT(size_t, ChunkSize = 1 << ChunkShift);
-
- typedef storage<InlineSize, MinHeapIncrement, Al> This;
- typedef Al Allocator;
- typedef typename Allocator::template rebind<char>::other CharAllocator;
- typedef detail::Link<CharAllocator> Link;
- typedef detail::Pool Pool;
- typedef std::vector<Link> Chain;
- typedef boost::array<Pool, NumPools> Pools;
-
- private:
- fixed_storage<InlineSize> fixed; // the inline fixed-sized storage which may be on the stack
- Chain chain; // heap-based storage
- Allocator alloc; // allocator for heap-based storage
- Pools pools; // pools of same-sized chunks
-
- void create_pools()
- {
- for (size_t n = 0; n < NumPools; ++n)
- {
- pools[n] = Pool(n*ChunkSize);
- }
- }
-
- public:
- storage()
- {
- create_pools();
- }
- storage(Allocator const &A)
- : alloc(A)
- {
- create_pools();
- }
- ~storage()
- {
- release();
- }
-
- void reset()
- {
- fixed.reset();
- BOOST_FOREACH(Pool&pool, pools)
- {
- pool.reset();
- }
- BOOST_FOREACH(Link &link, chain)
- {
- link.reset();
- }
- }
-
- void release()
- {
- reset();
- BOOST_FOREACH(Link &link, chain)
- {
- link.release();
- }
- chain.clear();
- }
-
- void *allocate(size_t num_bytes, size_t alignment = 1)
- {
- if (void *ptr = from_pool(num_bytes, alignment))
- return ptr;
- if (void *ptr = from_fixed(num_bytes, alignment))
- return ptr;
- return from_heap(num_bytes, alignment);
- }
-
- void *from_pool(size_t num_bytes, size_t alignment)
- {
- size_t bucket_num = (ChunkSize + num_bytes) >> ChunkShift;
- if (bucket_num >= NumPools)
- return 0;
- return pools[bucket_num].allocate(*this);
- }
-
- void *from_fixed(size_t num_bytes, size_t alignment)
- {
- return fixed.allocate(num_bytes, alignment);
- }
-
- void *from_heap(size_t num_bytes, size_t alignment)
- {
- if (MinHeapIncrement == 0)
- return 0;
- if (!chain.empty())
- {
- if (void *ptr = chain.front().allocate(num_bytes, alignment))
- {
- return ptr;
- }
- std::make_heap(chain.begin(), chain.end());
- if (void *ptr = chain.front().allocate(num_bytes, alignment))
- {
- return ptr;
- }
- }
- AddLink((std::max)(MinHeapIncrement, num_bytes*2));
- void *ptr = chain.front().allocate(num_bytes, alignment);
- if (ptr == 0)
- throw std::bad_alloc();
- return ptr;
- }
-
- void deallocate(void *ptr)
- {
- // do nothing
- }
-
- size_t max_size() const
- {
- return (std::numeric_limits<size_t>::max)();
- }
-
- size_t fixed_remaining() const
- {
- return fixed.remaining();
- }
-
- size_t remaining() const
- {
- return max_size();
- }
-
- size_t fixed_used() const
- {
- return fixed.used();
- }
-
- size_t heap_used() const
- {
- size_t count = 0;
- BOOST_FOREACH(Link const &link, chain)
- count += link.used();
- return count;
- }
-
- size_t used() const
- {
- return fixed_used() + heap_used();
- }
-
- size_t num_links() const
- {
- return chain.size();
- }
-
- // ------------------------------------------------------------------------
-
- template <class Ty>
- Ty *uninitialised_create()
- {
- return reinterpret_cast<Ty *>(allocate_bytes<sizeof(Ty)>());
- }
-
- template <class Ty>
- void construct(Ty *ptr, const boost::true_type& /*is_pod*/)
- {
- // do nothing
- }
-
- template <class Ty>
- void construct(Ty *ptr, const boost::false_type&)
- {
- new (ptr) Ty();
- }
-
- template <class Ty>
- Ty &create()
- {
- Ty *ptr = uninitialised_create<Ty>();
- construct(ptr, boost::is_pod<Ty>());
- return *ptr;
- }
-
- template <class Ty, class A0>
- Ty &create(A0 a0)
- {
- Ty *ptr = uninitialised_create<Ty>();
- new (ptr) Ty(a0);
- return *ptr;
- }
-
- template <class Ty, class A0, class A1>
- Ty &create(A0 a0, A1 a1)
- {
- Ty *ptr = uninitialised_create<Ty>();
- new (ptr) Ty(a0, a1);
- return *ptr;
- }
-
- template <class Ty>
- void destroy(Ty &object)
- {
- object.~Ty();
- }
-
- template <class Ty>
- void destroy(Ty const &object)
- {
- destroy(const_cast<Ty &>(object));
- }
-
- template <size_t N>
- char *allocate_bytes()
- {
- return allocate_bytes(N, boost::aligned_storage<N>::alignment);
- }
-
- char *allocate_bytes(size_t num_bytes, size_t alignment = 1)
- {
- return reinterpret_cast<char *>(allocate(num_bytes, alignment));
- }
-
- size_t get_cursor() const
- {
- return fixed.get_cursor();
- }
- void set_cursor(size_t n)
- {
- fixed.set_cursor(n);
- }
-
- private:
- void AddLink(size_t size)
- {
- chain.push_back(Link(alloc, size));
- std::make_heap(chain.begin(), chain.end());
- }
- };
+ namespace monotonic
+ {
+ /// storage that spans the stack/heap boundary.
+ ///
+ /// allocation requests first use inline fixed_storage of InlineSize bytes.
+ /// once that is exhausted, later requests are serviced from the heap.
+ ///
+ /// all allocations remain valid at all times.
+ template <size_t InlineSize, size_t MinHeapIncrement, class Alloc>
+ struct storage : storage_base
+ {
+ BOOST_STATIC_CONSTANT(size_t, NumPools = 8);
+ BOOST_STATIC_CONSTANT(size_t, ChunkShift = 4);
+ BOOST_STATIC_CONSTANT(size_t, ChunkSize = 1 << ChunkShift);
+
+ typedef storage<InlineSize, MinHeapIncrement, Alloc> This;
+ typedef Alloc Allocator;
+ typedef typename Allocator::template rebind<char>::other CharAllocator;
+ typedef detail::Link<CharAllocator> Link;
+ typedef detail::Pool Pool;
+ // allocations are always made from the stack, or from a pool the first link in the chain
+ typedef std::vector<Link, Alloc> Chain;
+ typedef boost::array<Pool, NumPools> Pools;
+
+ private:
+ fixed_storage<InlineSize> fixed; // the inline fixed-sized storage which may be on the stack
+ Chain chain; // heap-based storage
+ Allocator alloc; // allocator for heap-based storage
+ Pools pools; // pools of same-sized chunks
+
+ void create_pools()
+ {
+ for (size_t n = 0; n < NumPools; ++n)
+ {
+ pools[n] = Pool(n*ChunkSize);
+ }
+ }
+ protected:
+ template <size_t,size_t,class> friend struct stack;
+
+ public:
+ storage()
+ {
+ create_pools();
+ }
+ storage(Allocator const &A)
+ : alloc(A)
+ {
+ create_pools();
+ }
+ ~storage()
+ {
+ release();
+ }
+
+ void reset()
+ {
+ fixed.reset();
+ BOOST_FOREACH(Pool&pool, pools)
+ {
+ pool.reset();
+ }
+ BOOST_FOREACH(Link &link, chain)
+ {
+ link.reset();
+ }
+ }
+
+ void release()
+ {
+ reset();
+ BOOST_FOREACH(Link &link, chain)
+ {
+ link.release();
+ }
+ chain.clear();
+ }
+
+ struct Allocation
+ {
+ void *ptr;
+ size_t cursor;
+ Pool *pool;
+ Link *link;
+
+ Allocation()
+ : pool(0), link(0), cursor(0), ptr(0) { }
+
+ void undo()
+ {
+ if (pool)
+ {
+ pool->pop();
+ return;
+ }
+ if (link)
+ {
+ link->set_cursor(cursor);
+ return;
+ }
+ if (storage)
+ {
+ storage->set_cursor(cursor);
+ }
+ }
+ };
+ Allocation MakeAllocation(size_t num_bytes, size_t alignment = 4)
+ {
+ size_t bucket = (ChunkSize + num_bytes) >> ChunkShift;
+ if (bucket < NumPools)
+ {
+ if (void *ptr = from_pool(bucket, num_bytes, alignment))
+ return Allocation(bucket, ptr);
+ }
+ //if (fixed.
+ //if (void *ptr = from_fixed(num_bytes, alignment))
+ // return Allocation(
+ return from_heap(num_bytes, alignment);
+ }
+
+ public:
+ void *allocate(size_t num_bytes, size_t alignment = 1)
+ {
+ size_t pool = (ChunkSize + num_bytes) >> ChunkShift;
+ if (pool < NumPools)
+ {
+ if (void *ptr = from_pool(pool, num_bytes, alignment))
+ return ptr;
+ }
+ if (void *ptr = from_fixed(num_bytes, alignment))
+ return ptr;
+ return from_heap(num_bytes, alignment);
+ }
+
+ private:
+ friend detail::Pool;
+
+ void *from_pool(size_t bucket, size_t num_bytes, size_t alignment)
+ {
+ return pools[bucket].allocate(*this);
+ }
+
+ void *from_fixed(size_t num_bytes, size_t alignment)
+ {
+ return fixed.allocate(num_bytes, alignment);
+ }
+
+ void *from_heap(size_t num_bytes, size_t alignment)
+ {
+ if (MinHeapIncrement == 0)
+ return 0;
+ if (!chain.empty())
+ {
+ if (void *ptr = chain.front().allocate(num_bytes, alignment))
+ {
+ return ptr;
+ }
+ std::make_heap(chain.begin(), chain.end());
+ if (void *ptr = chain.front().allocate(num_bytes, alignment))
+ {
+ return ptr;
+ }
+ }
+ AddLink((std::max)(MinHeapIncrement, num_bytes*2));
+ void *ptr = chain.front().allocate(num_bytes, alignment);
+ if (ptr == 0)
+ throw std::bad_alloc();
+ return ptr;
+ }
+
+ public:
+ void deallocate(void *ptr)
+ {
+ // do nothing
+ }
+
+ size_t max_size() const
+ {
+ return (std::numeric_limits<size_t>::max)();
+ }
+
+ size_t fixed_remaining() const
+ {
+ return fixed.remaining();
+ }
+
+ size_t remaining() const
+ {
+ return max_size();
+ }
+
+ size_t fixed_used() const
+ {
+ return fixed.used();
+ }
+
+ size_t heap_used() const
+ {
+ size_t count = 0;
+ BOOST_FOREACH(Link const &link, chain)
+ count += link.used();
+ return count;
+ }
+
+ size_t used() const
+ {
+ return fixed_used() + heap_used();
+ }
+
+ size_t num_links() const
+ {
+ return chain.size();
+ }
+
+ // ------------------------------------------------------------------------
+
+ template <class Ty>
+ Ty *uninitialised_create()
+ {
+ return reinterpret_cast<Ty *>(allocate_bytes<sizeof(Ty)>());
+ }
+
+ template <class Ty>
+ void construct(Ty *ptr, const boost::true_type& /*is_pod*/)
+ {
+ // do nothing
+ }
+
+ template <class Ty>
+ void construct(Ty *ptr, const boost::false_type&)
+ {
+ new (ptr) Ty();
+ }
+
+ template <class Ty>
+ Ty &create()
+ {
+ Ty *ptr = uninitialised_create<Ty>();
+ construct(ptr, boost::is_pod<Ty>());
+ return *ptr;
+ }
+
+ template <class Ty, class A0>
+ Ty &create(A0 a0)
+ {
+ Ty *ptr = uninitialised_create<Ty>();
+ new (ptr) Ty(a0);
+ return *ptr;
+ }
+
+ template <class Ty, class A0, class A1>
+ Ty &create(A0 a0, A1 a1)
+ {
+ Ty *ptr = uninitialised_create<Ty>();
+ new (ptr) Ty(a0, a1);
+ return *ptr;
+ }
+
+ template <class Ty>
+ void destroy(Ty &object)
+ {
+ object.~Ty();
+ }
+
+ template <class Ty>
+ void destroy(Ty const &object)
+ {
+ destroy(const_cast<Ty &>(object));
+ }
+
+ template <size_t N>
+ char *allocate_bytes()
+ {
+ return allocate_bytes(N, boost::aligned_storage<N>::alignment);
+ }
+
+ char *allocate_bytes(size_t num_bytes, size_t alignment = 1)
+ {
+ return reinterpret_cast<char *>(allocate(num_bytes, alignment));
+ }
+
+ size_t get_cursor() const
+ {
+ return fixed.get_cursor();
+ }
+ void set_cursor(size_t n)
+ {
+ fixed.set_cursor(n);
+ }
+
+ private:
+ void AddLink(size_t size)
+ {
+ chain.push_back(Link(alloc, size));
+ std::make_heap(chain.begin(), chain.end());
+ }
+ };
 
- } // namespace monotonic
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/monotonic/storage_base.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/storage_base.hpp (original)
+++ sandbox/monotonic/boost/monotonic/storage_base.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -10,32 +10,32 @@
 
 namespace boost
 {
- namespace monotonic
- {
- /// base structure for different storage types
- struct storage_base
- {
- // reset the number of bytes used to zero
- virtual void reset() = 0;
-
- // reset(), and release all heap-based storage
- virtual void release() = 0;
-
- // the number of bytes to allocate, and the alignment to use
- virtual void *allocate(size_t num_bytes, size_t alignment) = 0;
-
- virtual void deallocate(void * ptr) = 0;
-
- virtual size_t max_size() const = 0;
-
- /// return the number of bytes used
- virtual size_t used() const = 0;
-
- /// return the number of bytes remaining
- virtual size_t remaining() const = 0;
- };
-
- } // namespace monotonic
+ namespace monotonic
+ {
+ /// base structure for different storage types
+ struct storage_base
+ {
+ // reset the number of bytes used to zero
+ virtual void reset() = 0;
+
+ // reset(), and release all heap-based storage
+ virtual void release() = 0;
+
+ // the number of bytes to allocate, and the alignment to use
+ virtual void *allocate(size_t num_bytes, size_t alignment) = 0;
+
+ virtual void deallocate(void * ptr) = 0;
+
+ virtual size_t max_size() const = 0;
+
+ /// return the number of bytes used
+ virtual size_t used() const = 0;
+
+ /// return the number of bytes remaining
+ virtual size_t remaining() const = 0;
+ };
+
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/monotonic/thread_local_storage.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/thread_local_storage.hpp (original)
+++ sandbox/monotonic/boost/monotonic/thread_local_storage.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -14,71 +14,71 @@
 
 namespace boost
 {
- namespace monotonic
- {
- namespace detail
- {
- template <class Region>
- struct storage_type<Region, thread_local_access_tag>
- {
- template <size_t N, size_t M, class Al>
- struct storage
- {
- typedef thread_local_storage<N,M,Al> type;
- };
- };
- }
-
- /// thread-local storage
- template <size_t InlineSize, size_t MinHeapSize, class Al>
- struct thread_local_storage : storage_base
- {
- typedef storage<InlineSize, MinHeapSize, Al> Storage;
- typedef boost::thread_specific_ptr<Storage> TLS_Storage;
- typedef thread_local_storage<InlineSize, MinHeapSize, Al> This;
-
- private:
- Storage store;
- TLS_Storage tls_store;
- static void no_delete(Storage *) { }
-
- public:
- thread_local_storage()
- : tls_store(&This::no_delete)
- {
- tls_store.reset(&store);
- }
- size_t used() const
- {
- return tls_store->used();
- }
- void reset()
- {
- tls_store->reset();
- }
- void release()
- {
- tls_store->release();
- }
- void *allocate(size_t num_bytes, size_t alignment)
- {
- return tls_store->allocate(num_bytes, alignment);
- }
- size_t remaining() const
- {
- return tls_store->remaining();
- }
- size_t fixed_remaining() const
- {
- return tls_store->fixed_remaining();
- }
- size_t max_size() const
- {
- return tls_store->max_size();
- }
- };
+ namespace monotonic
+ {
+ namespace detail
+ {
+ template <class Region>
+ struct storage_type<Region, thread_local_access_tag>
+ {
+ template <size_t N, size_t M, class Al>
+ struct storage
+ {
+ typedef thread_local_storage<N,M,Al> type;
+ };
+ };
+ }
+
+ /// thread-local storage
+ template <size_t InlineSize, size_t MinHeapSize, class Al>
+ struct thread_local_storage : storage_base
+ {
+ typedef storage<InlineSize, MinHeapSize, Al> Storage;
+ typedef boost::thread_specific_ptr<Storage> TLS_Storage;
+ typedef thread_local_storage<InlineSize, MinHeapSize, Al> This;
+
+ private:
+ Storage store;
+ TLS_Storage tls_store;
+ static void no_delete(Storage *) { }
+
+ public:
+ thread_local_storage()
+ : tls_store(&This::no_delete)
+ {
+ tls_store.reset(&store);
+ }
+ size_t used() const
+ {
+ return tls_store->used();
+ }
+ void reset()
+ {
+ tls_store->reset();
+ }
+ void release()
+ {
+ tls_store->release();
+ }
+ void *allocate(size_t num_bytes, size_t alignment)
+ {
+ return tls_store->allocate(num_bytes, alignment);
+ }
+ size_t remaining() const
+ {
+ return tls_store->remaining();
+ }
+ size_t fixed_remaining() const
+ {
+ return tls_store->fixed_remaining();
+ }
+ size_t max_size() const
+ {
+ return tls_store->max_size();
+ }
+ };
 
- } // namespace monotonic
+ } // namespace monotonic
 
 } // namespace boost
 

Modified: sandbox/monotonic/boost/object_model/builder.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/builder.hpp (original)
+++ sandbox/monotonic/boost/object_model/builder.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -18,48 +18,48 @@
 template <class T, class Reg>
 struct builder
 {
- typedef Reg registry_type;
- typedef type::traits<T> type_traits;
- typedef typename Reg::traits_type system_traits;
- typedef typename registry_type::template rebind_klass<T>::type class_type;
+ typedef Reg registry_type;
+ typedef type::traits<T> type_traits;
+ typedef typename Reg::traits_type system_traits;
+ typedef typename registry_type::template rebind_klass<T>::type class_type;
 
 private:
- class_type *my_klass;
+ class_type *my_klass;
 
 public:
- builder(registry_type &reg)
- {
- methods.my_klass = methods.fields.my_klass = my_klass = reg.register_class<T>();
- methods.factory = methods.fields.factory = &reg;
- }
- struct methods_type
- {
- struct fields_type
- {
- template <class Field>
- fields_type &operator()(const char *name, Field field)
- {
- return *this;
- }
- registry_type *factory;
- class_type *my_klass;
- } fields;
-
- template <class Method>
- methods_type &operator()(const char *name, Method method)
- {
- my_klass->add_method(name, detail::make_method(method, *factory));
- return *this;
- }
- registry_type *factory;
- class_type *my_klass;
- } methods;
+ builder(registry_type &reg)
+ {
+ methods.my_klass = methods.fields.my_klass = my_klass = reg.register_class<T>();
+ methods.factory = methods.fields.factory = &reg;
+ }
+ struct methods_type
+ {
+ struct fields_type
+ {
+ template <class Field>
+ fields_type &operator()(const char *name, Field field)
+ {
+ return *this;
+ }
+ registry_type *factory;
+ class_type *my_klass;
+ } fields;
+
+ template <class Method>
+ methods_type &operator()(const char *name, Method method)
+ {
+ my_klass->add_method(name, detail::make_method(method, *factory));
+ return *this;
+ }
+ registry_type *factory;
+ class_type *my_klass;
+ } methods;
 };
 
 template <class T, class Registry>
 builder<T,Registry> class_builder(Registry &reg)
 {
- return builder<T,Registry>(reg);
+ return builder<T,Registry>(reg);
 }
 
 BOOST_OM_END

Modified: sandbox/monotonic/boost/object_model/class.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/class.hpp (original)
+++ sandbox/monotonic/boost/object_model/class.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -19,45 +19,45 @@
 template <class T, class Registry>
 struct klass : detail::klass_base<typename Registry>
 {
- typedef typename Registry::traits_type system_traits;
- typedef detail::klass_base<Registry> klass_base_type;
- typedef typename system_traits::label_type label_type;
- typedef typename Registry::rebind_storage<T>::type storage_type;
- typedef typename system_traits::allocator_type::template rebind<storage_type>::other allocator_type;
- typedef type::traits<T> traits;
+ typedef typename Registry::traits_type system_traits;
+ typedef detail::klass_base<Registry> klass_base_type;
+ typedef typename system_traits::label_type label_type;
+ typedef typename Registry::rebind_storage<T>::type storage_type;
+ typedef typename system_traits::allocator_type::template rebind<storage_type>::other allocator_type;
+ typedef type::traits<T> traits;
 
 private:
- Registry &factory;
- mutable allocator_type allocator;
+ Registry &factory;
+ mutable allocator_type allocator;
 
 public:
- klass(Registry &reg)
- : klass_base_type(reg, traits::name, traits::type_number), factory(reg), allocator(reg.get_allocator()) { }
+ klass(Registry &reg)
+ : klass_base_type(reg, traits::name, traits::type_number), factory(reg), allocator(reg.get_allocator()) { }
 
- generic::object &create() const
- {
- storage_type *store = allocator.allocate(1);
- //allocator.construct(store);
- new (store) storage_type();
- store->construct(factory, *this, factory.get_next_handle());
- return *store;
- }
-
- storage_type &create(typename traits::const_reference_type init) const
- {
- storage_type *store = allocator.allocate(1);
- //allocator.construct(store);
- new (store) storage_type(init);
- store->construct(factory, *this, factory.get_next_handle());
- return *store;
- }
-
- void destroy(generic::object &obj) const
- {
- storage_type *store = &static_cast<storage_type &>(obj);
- allocator.destroy(store);
- allocator.deallocate(store, 1);
- }
+ generic::object &create() const
+ {
+ storage_type *store = allocator.allocate(1);
+ //allocator.construct(store);
+ new (store) storage_type();
+ store->construct(factory, *this, factory.get_next_handle());
+ return *store;
+ }
+
+ storage_type &create(typename traits::const_reference_type init) const
+ {
+ storage_type *store = allocator.allocate(1);
+ //allocator.construct(store);
+ new (store) storage_type(init);
+ store->construct(factory, *this, factory.get_next_handle());
+ return *store;
+ }
+
+ void destroy(generic::object &obj) const
+ {
+ storage_type *store = &static_cast<storage_type &>(obj);
+ allocator.destroy(store);
+ allocator.deallocate(store, 1);
+ }
 
 };
 

Modified: sandbox/monotonic/boost/object_model/containers/vector.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/containers/vector.hpp (original)
+++ sandbox/monotonic/boost/object_model/containers/vector.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -16,103 +16,103 @@
 
 namespace containers
 {
- template <class Alloc>
- struct vector
- {
- //typedef boost::containers::vector<generic::object, Alloc> implementation;
- typedef std::vector<generic::object, Alloc> implementation;
- typedef typename implementation::value_type value_type;
- typedef typename implementation::iterator iterator;
- typedef typename implementation::const_iterator const_iterator;
- typedef typename implementation::reference reference;
- typedef typename implementation::const_reference const_reference;
-
- private:
- implementation impl;
-
- public:
- size_t size() const
- {
- return impl.size();
- }
-
- const_iterator begin() const
- {
- return impl.begin();
- }
- iterator begin()
- {
- return impl.begin();
- }
- const_iterator end() const
- {
- return impl.end();
- }
- iterator end()
- {
- return impl.end();
- }
- const_reference front() const
- {
- return impl.front();
- }
- reference front()
- {
- return impl.front();
- }
- const_reference back() const
- {
- return impl.back();
- }
- reference back()
- {
- return impl.back();
- }
- void push_back(generic::object obj)
- {
- impl.push_back(obj);
- }
- void pop_back()
- {
- impl.pop_back();
- }
- generic::object pop()
- {
- generic::object top = back();
- impl.pop_back();
- return top;
- }
- reference at(size_t index)
- {
- return impl.at(index);
- }
- const_reference at(size_t index) const
- {
- return impl.at(index);
- }
- reference operator[](size_t index)
- {
- return impl[index];
- }
- const_reference operator[](size_t index) const
- {
- return impl[index];
- }
- };
+ template <class Alloc>
+ struct vector
+ {
+ //typedef boost::containers::vector<generic::object, Alloc> implementation;
+ typedef std::vector<generic::object, Alloc> implementation;
+ typedef typename implementation::value_type value_type;
+ typedef typename implementation::iterator iterator;
+ typedef typename implementation::const_iterator const_iterator;
+ typedef typename implementation::reference reference;
+ typedef typename implementation::const_reference const_reference;
+
+ private:
+ implementation impl;
+
+ public:
+ size_t size() const
+ {
+ return impl.size();
+ }
+
+ const_iterator begin() const
+ {
+ return impl.begin();
+ }
+ iterator begin()
+ {
+ return impl.begin();
+ }
+ const_iterator end() const
+ {
+ return impl.end();
+ }
+ iterator end()
+ {
+ return impl.end();
+ }
+ const_reference front() const
+ {
+ return impl.front();
+ }
+ reference front()
+ {
+ return impl.front();
+ }
+ const_reference back() const
+ {
+ return impl.back();
+ }
+ reference back()
+ {
+ return impl.back();
+ }
+ void push_back(generic::object obj)
+ {
+ impl.push_back(obj);
+ }
+ void pop_back()
+ {
+ impl.pop_back();
+ }
+ generic::object pop()
+ {
+ generic::object top = back();
+ impl.pop_back();
+ return top;
+ }
+ reference at(size_t index)
+ {
+ return impl.at(index);
+ }
+ const_reference at(size_t index) const
+ {
+ return impl.at(index);
+ }
+ reference operator[](size_t index)
+ {
+ return impl[index];
+ }
+ const_reference operator[](size_t index) const
+ {
+ return impl[index];
+ }
+ };
 
 } // namespace containers
 
 namespace type
 {
- /// the type-traits for a vector with any allocator are the same
- template <class Al>
- struct traits<containers::vector<Al> > : traits_base<containers::vector<Al>, number::Vector >
- {
- BOOST_STATIC_CONSTANT(number::value_type, type_number = number::Vector );
- static const char *name;
- };
- template <class Al>
- const char *traits<containers::vector<Al> >::name = "vector";
+ /// the type-traits for a vector with any allocator are the same
+ template <class Al>
+ struct traits<containers::vector<Al> > : traits_base<containers::vector<Al>, number::Vector >
+ {
+ BOOST_STATIC_CONSTANT(number::value_type, type_number = number::Vector );
+ static const char *name;
+ };
+ template <class Al>
+ const char *traits<containers::vector<Al> >::name = "vector";
 }
 
 BOOST_OM_END

Modified: sandbox/monotonic/boost/object_model/detail/allocator.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/detail/allocator.hpp (original)
+++ sandbox/monotonic/boost/object_model/detail/allocator.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -15,11 +15,11 @@
 
 namespace detail
 {
- template <class Alloc, class T>
- struct rebind
- {
- typedef typename Alloc::template rebind<T>::other type;
- };
+ template <class Alloc, class T>
+ struct rebind
+ {
+ typedef typename Alloc::template rebind<T>::other type;
+ };
 }
 
 BOOST_OM_END

Modified: sandbox/monotonic/boost/object_model/detail/base_type.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/detail/base_type.hpp (original)
+++ sandbox/monotonic/boost/object_model/detail/base_type.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -19,32 +19,32 @@
 
 namespace detail
 {
- template <class T>
- struct remove_const_and_reference
- {
- typedef typename boost::remove_reference<T>::type T0;
- typedef typename boost::remove_const<T0>::type type;
- };
-
- template <class T>
- struct remove_object_wrap
- {
- typedef T type;
- };
-
- template <class T>
- struct remove_object_wrap<object<T> >
- {
- typedef T type;
- };
-
- /// remove any reference-ness or const-ness from a C++ type, and also strip object<> from it
- template <class T>
- struct base_type
- {
- typedef typename remove_const_and_reference<T>::type T0;
- typedef typename remove_object_wrap<T0>::type type;
- };
+ template <class T>
+ struct remove_const_and_reference
+ {
+ typedef typename boost::remove_reference<T>::type T0;
+ typedef typename boost::remove_const<T0>::type type;
+ };
+
+ template <class T>
+ struct remove_object_wrap
+ {
+ typedef T type;
+ };
+
+ template <class T>
+ struct remove_object_wrap<object<T> >
+ {
+ typedef T type;
+ };
+
+ /// remove any reference-ness or const-ness from a C++ type, and also strip object<> from it
+ template <class T>
+ struct base_type
+ {
+ typedef typename remove_const_and_reference<T>::type T0;
+ typedef typename remove_object_wrap<T0>::type type;
+ };
 
 } // namespace detail
 

Modified: sandbox/monotonic/boost/object_model/detail/class_base.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/detail/class_base.hpp (original)
+++ sandbox/monotonic/boost/object_model/detail/class_base.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -17,55 +17,55 @@
 
 namespace detail
 {
- template <class Registry>
- struct klass_base : generic::klass
- {
- typedef typename Registry::identifier_type Label;
- typedef typename Registry::allocator_type allocator_type;
-
- // TODO: use unordered_map
- typedef std::map<Label, generic::property const *, std::less<Label>, allocator_type> properties_type;
- typedef std::map<Label, generic::method<Registry> const *, std::less<Label>, allocator_type> methods_type;
-
- private:
- properties_type properties;
- methods_type methods;
- Registry &factory;
-
- public:
- klass_base(Registry &reg, generic::class_name ident, type::number num)
- : generic::klass(ident, num), factory(reg)
- {
- }
- ~klass_base()
- {
- BOOST_FOREACH(methods_type::value_type &val, methods)
- {
- factory.allocator_destroy_deallocate(const_cast<generic::method<Registry> *>(val.second));
- }
- }
-
- void add_method(Label const &name, generic::method<Registry> const *meth)
- {
- methods[name] = meth;
- }
-
- generic::method<Registry> const *get_method(Label const &name) const
- {
- methods_type::const_iterator iter = methods.find(name);
- return iter == methods.end() ? 0 : iter->second;
- }
-
- bool has_method(Label const &name) const
- {
- return methods.find(name) != methods.end();
- }
-
- bool has_field(Label const &name) const
- {
- return properties.find(name) != properties.end();
- }
- };
+ template <class Registry>
+ struct klass_base : generic::klass
+ {
+ typedef typename Registry::identifier_type Label;
+ typedef typename Registry::allocator_type allocator_type;
+
+ // TODO: use unordered_map
+ typedef std::map<Label, generic::property const *, std::less<Label>, allocator_type> properties_type;
+ typedef std::map<Label, generic::method<Registry> const *, std::less<Label>, allocator_type> methods_type;
+
+ private:
+ properties_type properties;
+ methods_type methods;
+ Registry &factory;
+
+ public:
+ klass_base(Registry &reg, generic::class_name ident, type::number num)
+ : generic::klass(ident, num), factory(reg)
+ {
+ }
+ ~klass_base()
+ {
+ BOOST_FOREACH(methods_type::value_type &val, methods)
+ {
+ factory.allocator_destroy_deallocate(const_cast<generic::method<Registry> *>(val.second));
+ }
+ }
+
+ void add_method(Label const &name, generic::method<Registry> const *meth)
+ {
+ methods[name] = meth;
+ }
+
+ generic::method<Registry> const *get_method(Label const &name) const
+ {
+ methods_type::const_iterator iter = methods.find(name);
+ return iter == methods.end() ? 0 : iter->second;
+ }
+
+ bool has_method(Label const &name) const
+ {
+ return methods.find(name) != methods.end();
+ }
+
+ bool has_field(Label const &name) const
+ {
+ return properties.find(name) != properties.end();
+ }
+ };
 
 } // namespace detail
 

Modified: sandbox/monotonic/boost/object_model/detail/make_method.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/detail/make_method.hpp (original)
+++ sandbox/monotonic/boost/object_model/detail/make_method.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -17,87 +17,87 @@
 
 namespace detail
 {
- // TODO: move these to be methods of detail::class_base<Reg>
+ // TODO: move these to be methods of detail::class_base<Reg>
 
- template <class Klass, class Reg>
- generic::method<Reg> *make_method(void (Klass::*M)(), Reg &reg)
- {
- return reg.allocator_create<method<Reg, void, Klass, boost::mpl::vector<>, false> >(M);
- }
-
- template <class Ret, class Klass, class Reg>
- generic::method<Reg> *make_method(Ret (Klass::*M)(), Reg &reg)
- {
- return reg.allocator_create<method<Reg, Ret, Klass, boost::mpl::vector<>, false> >(M);
- }
-
- template <class Klass, class Reg>
- generic::method<Reg> *make_method(void (Klass::*M)() const, Reg &reg)
- {
- return reg.allocator_create<method<Reg, void, Klass, boost::mpl::vector<>, true> >(M);
- }
-
- template <class Ret, class Klass, class Reg>
- generic::method<Reg> *make_method(Ret (Klass::*M)() const, Reg &reg)
- {
- return reg.allocator_create<method<Reg, Ret, Klass, boost::mpl::vector<>, true> >(M);
- }
-
- // ---------------------------------- arity = 1
-
- template <class Klass, class Reg, class A0>
- generic::method<Reg> *make_method(void (Klass::*M)(A0), Reg &reg)
- {
- return reg.allocator_create<method<Reg, void, Klass, boost::mpl::vector<A0>, false> >(M);
- }
-
- template <class Ret, class Klass, class Reg, class A0>
- generic::method<Reg> *make_method(Ret (Klass::*M)(A0), Reg &reg)
- {
- return reg.allocator_create<method<Reg, Ret, Klass, boost::mpl::vector<A0>, false> >(M);
- }
-
- template <class Klass, class Reg, class A0>
- generic::method<Reg> *make_method(void (Klass::*M)(A0) const, Reg &reg)
- {
- return reg.allocator_create<method<Reg, void, Klass, boost::mpl::vector<A0>, true> >(M);
- }
-
- template <class Ret, class Klass, class Reg, class A0>
- generic::method<Reg> *make_method(Ret (Klass::*M)(A0) const, Reg &reg)
- {
- return reg.allocator_create<method<Reg, Ret, Klass, boost::mpl::vector<A0>, true> >(M);
- }
-
- /*
-
- // ---------------------------------- arity = 2
-
- template <class Klass, class R, class A0, class A1>
- generic::method<Reg> *MakeMethod(R (Klass::*M)(A0,A1))
- {
- return new Method<R, Klass, boost::mpl::vector<A0,A1>, false>(M);
- }
-
- template <class Klass, class R, class A0, class A1>
- generic::method<Reg> *MakeMethod(R (Klass::*M)(A0,A1) const)
- {
- return new Method<R, Klass, boost::mpl::vector<A0,A1>, true>(M);
- }
-
- // ---------------------------------- arity = 3
-
- template <class Klass, class R, class A0, class A1, class A2>
- generic::method<Reg> *MakeMethod(R (Klass::*M)(A0,A1,A2))
- {
- return new Method<R, Klass, boost::mpl::vector<A0,A1,A2>, false>(M);
- }
-
- template <class Klass, class R, class A0, class A1, class A2>
- generic::method<Reg> *MakeMethod(R (Klass::*M)(A0,A1,A2) const)
- {
- return new Method<R, Klass, boost::mpl::vector<A0,A1,A2>, true>(M);
- }
+ template <class Klass, class Reg>
+ generic::method<Reg> *make_method(void (Klass::*M)(), Reg &reg)
+ {
+ return reg.allocator_create<method<Reg, void, Klass, boost::mpl::vector<>, false> >(M);
+ }
+
+ template <class Ret, class Klass, class Reg>
+ generic::method<Reg> *make_method(Ret (Klass::*M)(), Reg &reg)
+ {
+ return reg.allocator_create<method<Reg, Ret, Klass, boost::mpl::vector<>, false> >(M);
+ }
+
+ template <class Klass, class Reg>
+ generic::method<Reg> *make_method(void (Klass::*M)() const, Reg &reg)
+ {
+ return reg.allocator_create<method<Reg, void, Klass, boost::mpl::vector<>, true> >(M);
+ }
+
+ template <class Ret, class Klass, class Reg>
+ generic::method<Reg> *make_method(Ret (Klass::*M)() const, Reg &reg)
+ {
+ return reg.allocator_create<method<Reg, Ret, Klass, boost::mpl::vector<>, true> >(M);
+ }
+
+ // ---------------------------------- arity = 1
+
+ template <class Klass, class Reg, class A0>
+ generic::method<Reg> *make_method(void (Klass::*M)(A0), Reg &reg)
+ {
+ return reg.allocator_create<method<Reg, void, Klass, boost::mpl::vector<A0>, false> >(M);
+ }
+
+ template <class Ret, class Klass, class Reg, class A0>
+ generic::method<Reg> *make_method(Ret (Klass::*M)(A0), Reg &reg)
+ {
+ return reg.allocator_create<method<Reg, Ret, Klass, boost::mpl::vector<A0>, false> >(M);
+ }
+
+ template <class Klass, class Reg, class A0>
+ generic::method<Reg> *make_method(void (Klass::*M)(A0) const, Reg &reg)
+ {
+ return reg.allocator_create<method<Reg, void, Klass, boost::mpl::vector<A0>, true> >(M);
+ }
+
+ template <class Ret, class Klass, class Reg, class A0>
+ generic::method<Reg> *make_method(Ret (Klass::*M)(A0) const, Reg &reg)
+ {
+ return reg.allocator_create<method<Reg, Ret, Klass, boost::mpl::vector<A0>, true> >(M);
+ }
+
+ /*
+
+ // ---------------------------------- arity = 2
+
+ template <class Klass, class R, class A0, class A1>
+ generic::method<Reg> *MakeMethod(R (Klass::*M)(A0,A1))
+ {
+ return new Method<R, Klass, boost::mpl::vector<A0,A1>, false>(M);
+ }
+
+ template <class Klass, class R, class A0, class A1>
+ generic::method<Reg> *MakeMethod(R (Klass::*M)(A0,A1) const)
+ {
+ return new Method<R, Klass, boost::mpl::vector<A0,A1>, true>(M);
+ }
+
+ // ---------------------------------- arity = 3
+
+ template <class Klass, class R, class A0, class A1, class A2>
+ generic::method<Reg> *MakeMethod(R (Klass::*M)(A0,A1,A2))
+ {
+ return new Method<R, Klass, boost::mpl::vector<A0,A1,A2>, false>(M);
+ }
+
+ template <class Klass, class R, class A0, class A1, class A2>
+ generic::method<Reg> *MakeMethod(R (Klass::*M)(A0,A1,A2) const)
+ {
+ return new Method<R, Klass, boost::mpl::vector<A0,A1,A2>, true>(M);
+ }
 */
 
 }

Modified: sandbox/monotonic/boost/object_model/detail/method_pointer.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/detail/method_pointer.hpp (original)
+++ sandbox/monotonic/boost/object_model/detail/method_pointer.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -22,280 +22,280 @@
 
 namespace detail
 {
- template <class Reg, bool IsKonst, bool IsVoid, int Arity, class Return, class Klass, class Args>
- struct method_pointer;
+ template <class Reg, bool IsKonst, bool IsVoid, int Arity, class Return, class Klass, class Args>
+ struct method_pointer;
 
 
- //----------------------------------------------------------- arity = 0
- struct method_pointerBase0
- {
- template <class OI>
- void AddArgs(OI)
- {
- }
- };
- template <class Registry, class Return, class Klass, class Args>
- struct method_pointer<Registry, false, false, 0, Return, Klass, Args> : method_pointerBase0
- {
- typedef Return (Klass::*method_type)();
- method_type method;
- method_pointer(method_type M) : method(M) { }
- void operator()(generic::object object, typename Registry::vector_type &stack) const
- {
- Registry &reg = static_cast<Registry &>(object.get_registry());
- stack.push_back(reg.create((reg.deref<Klass>(object).*method)()));
- }
- };
-
- template <class Registry, class Return, class Klass, class Args>
- struct method_pointer<Registry, true, false, 0, Return, Klass, Args> : method_pointerBase0
- {
- typedef Return (Klass::*method_type)() const;
- method_type method;
- method_pointer(method_type M) : method(M) { }
- void operator()(generic::const_object object, typename Registry::vector_type &stack) const
- {
- Registry &reg = static_cast<Registry &>(object.get_registry());
- stack.push_back(reg.create((reg.const_deref<Klass>(object).*method)()));
- }
- };
- template <class Registry, class Return, class Klass, class Args>
- struct method_pointer<Registry, false, true, 0, Return, Klass, Args> : method_pointerBase0
- {
- typedef Return (Klass::*method_type)();
- method_type method;
- method_pointer(method_type M) : method(M) { }
- void operator()(generic::mutable_object object, typename Registry::vector_type &stack) const
- {
- Registry &reg = static_cast<Registry &>(object.get_registry());
- (reg.const_deref<Klass>(object).*method)();
- }
- };
-
- template <class Registry, class Return, class Klass, class Args>
- struct method_pointer<Registry, true, true, 0, Return, Klass, Args> : method_pointerBase0
- {
- typedef Return (Klass::*method_type)() const;
- method_type method;
- method_pointer(method_type M) : method(M) { }
- void operator()(generic::const_object object, typename Registry::vector_type &stack) const
- {
- Registry &reg = static_cast<Registry &>(object.get_registry());
- (reg.const_deref<Klass>(object).*method)();
- }
- };
-
- //----------------------------------------------------------- arity = 1
- template <class Args>
- struct method_pointerBase1 : method_pointerBase0
- {
- typedef typename boost::mpl::at_c<Args, 0>::type A0;
- typedef typename detail::base_type<A0>::type P0;
- //typedef Pointer<B0> P0;
- template <class OI>
- void AddArgs(OI P)
- {
- method_pointerBase0::AddArgs(P);
- *P++ = type::make_specifier<A0>();
- }
- };
- template <class Registry, class Return, class Klass, class Args>
- struct method_pointer<Registry, false, false, 1, Return, Klass, Args> : method_pointerBase1<Args>
- {
- typedef Return (Klass::*method_type)(A0);
- method_type method;
- method_pointer(method_type M) : method(M) { }
- void operator()(generic::mutable_object object, typename Registry::vector_type &stack) const
- {
- Registry &reg = static_cast<Registry &>(object.get_registry());
- generic::object a0 = stack.pop();
- stack.push_back(reg.create((reg.deref<Klass>(object).*method)(reg.deref<P0>(a0))));
- }
- };
- template <class Registry, class Return, class Klass, class Args>
- struct method_pointer<Registry, true, false, 1, Return, Klass, Args> : method_pointerBase1<Args>
- {
- typedef Return (Klass::*method_type)(A0) const;
- method_type method;
- method_pointer(method_type M) : method(M) { }
- void operator()(generic::const_object const object, typename Registry::vector_type &stack) const
- {
- Registry &reg = static_cast<Registry &>(object.get_registry());
- generic::object a0 = stack.pop();
- stack.push_back(reg.create((reg.const_deref<Klass>(object).*method)(reg.deref<P0>(a0))));
- }
- };
- template <class Registry, class Return, class Klass, class Args>
- struct method_pointer<Registry, false, true, 1, Return, Klass, Args> : method_pointerBase1<Args>
- {
- typedef Return (Klass::*method_type)(A0);
- method_type method;
- method_pointer(method_type M) : method(M) { }
- void operator()(generic::object object, typename Registry::vector_type &stack) const
- {
- Registry &reg = static_cast<Registry &>(object.get_registry());
- generic::object a0 = stack.pop();
- (reg.const_deref<Klass>(object).*method)(reg.deref<P0>(a0))
- }
- };
- template <class Registry, class Return, class Klass, class Args>
- struct method_pointer<Registry, true, true, 1, Return, Klass, Args> : method_pointerBase1<Args>
- {
- typedef Return (Klass::*method_type)(A0) const;
- method_type method;
- method_pointer(method_type M) : method(M) { }
- void operator()(generic::const_object const object, typename Registry::vector_type &stack) const
- {
- Registry &reg = static_cast<Registry &>(object.get_registry());
- generic::object a0 = stack.pop();
- (reg.const_deref<Klass>(object).*method)(reg.deref<P0>(a0))
- }
- };
-
- /*
- //----------------------------------------------------------- arity = 2
- template <class Args>
- struct method_pointerBase2 : method_pointerBase1<Args>
- {
- typedef typename boost::mpl::at_c<Args, 1>::type A1;
- typedef typename BaseType<A1>::Type B1;
- typedef Pointer<B1> P1;
- template <class OI>
- void AddArgs(OI P)
- {
- method_pointerBase1<Args>::AddArgs(P);
- *P++ = Type::MakeType<A1>::Create();
- }
- };
- template <class Return, class Klass, class Args>
- struct method_pointer<false, false, 2, Return, Klass, Args> : method_pointerBase2<Args>
- {
- typedef Return (Klass::*method_type)(A0,A1);
- method_type method;
- method_pointer(method_type M) : method(M) { }
- void operator()(generic::object &object, typename Registry::vector_type &stack) const
- {
- P1 a1 = stack.pop();
- P0 a0 = stack.pop();
- stack.push_back(object.New((Deref<Klass>(object).*method)(*a0, *a1)));
- }
- };
- template <class Return, class Klass, class Args>
- struct method_pointer<true, false, 2, Return, Klass, Args> : method_pointerBase2<Args>
- {
- typedef Return (Klass::*method_type)(A0,A1) const;
- method_type method;
- method_pointer(method_type M) : method(M) { }
- void operator()(generic::object const &object, typename Registry::vector_type &stack) const
- {
- P1 a1 = stack.pop();
- P0 a0 = stack.pop();
- stack.push_back(object.New((Deref<Klass>(object).*method)(*a0, *a1)));
- }
- };
- template <class Return, class Klass, class Args>
- struct method_pointer<false, true, 2, Return, Klass, Args> : method_pointerBase2<Args>
- {
- typedef Return (Klass::*method_type)(A0,A1);
- method_type method;
- method_pointer(method_type M) : method(M) { }
- void operator()(generic::object &object, typename Registry::vector_type &stack) const
- {
- P1 a1 = stack.pop();
- P0 a0 = stack.pop();
- (Deref<Klass>(object).*method)(*a0, *a1);
- }
- };
- template <class Return, class Klass, class Args>
- struct method_pointer<true, true, 2, Return, Klass, Args> : method_pointerBase2<Args>
- {
- typedef Return (Klass::*method_type)(A0, A1) const;
- method_type method;
- method_pointer(method_type M) : method(M) { }
- void operator()(generic::object const &object, typename Registry::vector_type &stack) const
- {
- P1 a1 = stack.pop();
- P0 a0 = stack.pop();
- (Deref<Klass>(object).*method)(*a0, *a1);
- }
- };
- //----------------------------------------------------------- arity = 3
- template <class Args>
- struct method_pointerBase3 : method_pointerBase2<Args>
- {
- typedef typename boost::mpl::at_c<Args, 2>::type A2;
- typedef typename BaseType<A2>::Type B2;
- typedef Pointer<B2> P2;
- template <class OI>
- void AddArgs(OI P)
- {
- method_pointerBase2<Args>::AddArgs(P);
- *P++ = Type::MakeType<A2>::Create();
- }
- };
- template <class Return, class Klass, class Args>
- struct method_pointer<false, false, 3, Return, Klass, Args> : method_pointerBase3<Args>
- {
- typedef Return (Klass::*method_type)(A0,A1,A2);
- method_type method;
- method_pointer(method_type M) : method(M) { }
- void operator()(generic::object &object, typename Registry::vector_type &stack) const
- {
- P2 a2 = stack.pop();
- P1 a1 = stack.pop();
- P0 a0 = stack.pop();
- stack.push_back(object.New((Deref<Klass>(object).*method)(*a0, *a1, *a2)));
- }
- };
- template <class Return, class Klass, class Args>
- struct method_pointer<true, false, 3, Return, Klass, Args> : method_pointerBase3<Args>
- {
- typedef Return (Klass::*method_type)(A0,A1,A2) const;
- method_type method;
- method_pointer(method_type M) : method(M) { }
- void operator()(generic::object const &object, typename Registry::vector_type &stack) const
- {
- P2 a2 = stack.pop();
- P1 a1 = stack.pop();
- P0 a0 = stack.pop();
- stack.push_back(object.New((Deref<Klass>(object).*method)(*a0, *a1, *a2)));
- }
- };
- template <class Return, class Klass, class Args>
- struct method_pointer<false, true, 3, Return, Klass, Args> : method_pointerBase3<Args>
- {
- typedef Return (Klass::*method_type)(A0,A1,A2);
- method_type method;
- method_pointer(method_type M) : method(M) { }
- void operator()(generic::object &object, typename Registry::vector_type &stack) const
- {
- P2 a2 = stack.pop();
- P1 a1 = stack.pop();
- P0 a0 = stack.pop();
- (Deref<Klass>(object).*method)(*a0, *a1, *a2);
- }
- };
- template <class Return, class Klass, class Args>
- struct method_pointer<true, true, 3, Return, Klass, Args> : method_pointerBase3<Args>
- {
- typedef Return (Klass::*method_type)(A0, A1,A2) const;
- method_type method;
- method_pointer(method_type M) : method(M) { }
- void operator()(generic::object const &object, typename Registry::vector_type &stack) const
- {
- P2 a2 = stack.pop();
- P1 a1 = stack.pop();
- P0 a0 = stack.pop();
- (Deref<Klass>(object).*method)(*a0, *a1, *a2);
- }
- };
-
- */
- template <class Reg, class Rty, class Klass, class Args, bool Konst>
- struct make_method_pointer
- {
- typedef method_pointer<Reg, Konst, boost::is_same<void, Rty>::value, boost::mpl::size<Args>::value, Rty, Klass, Args> type;
- };
+ //----------------------------------------------------------- arity = 0
+ struct method_pointerBase0
+ {
+ template <class OI>
+ void AddArgs(OI)
+ {
+ }
+ };
+ template <class Registry, class Return, class Klass, class Args>
+ struct method_pointer<Registry, false, false, 0, Return, Klass, Args> : method_pointerBase0
+ {
+ typedef Return (Klass::*method_type)();
+ method_type method;
+ method_pointer(method_type M) : method(M) { }
+ void operator()(generic::object object, typename Registry::vector_type &stack) const
+ {
+ Registry &reg = static_cast<Registry &>(object.get_registry());
+ stack.push_back(reg.create((reg.deref<Klass>(object).*method)()));
+ }
+ };
+
+ template <class Registry, class Return, class Klass, class Args>
+ struct method_pointer<Registry, true, false, 0, Return, Klass, Args> : method_pointerBase0
+ {
+ typedef Return (Klass::*method_type)() const;
+ method_type method;
+ method_pointer(method_type M) : method(M) { }
+ void operator()(generic::const_object object, typename Registry::vector_type &stack) const
+ {
+ Registry &reg = static_cast<Registry &>(object.get_registry());
+ stack.push_back(reg.create((reg.const_deref<Klass>(object).*method)()));
+ }
+ };
+ template <class Registry, class Return, class Klass, class Args>
+ struct method_pointer<Registry, false, true, 0, Return, Klass, Args> : method_pointerBase0
+ {
+ typedef Return (Klass::*method_type)();
+ method_type method;
+ method_pointer(method_type M) : method(M) { }
+ void operator()(generic::mutable_object object, typename Registry::vector_type &stack) const
+ {
+ Registry &reg = static_cast<Registry &>(object.get_registry());
+ (reg.const_deref<Klass>(object).*method)();
+ }
+ };
+
+ template <class Registry, class Return, class Klass, class Args>
+ struct method_pointer<Registry, true, true, 0, Return, Klass, Args> : method_pointerBase0
+ {
+ typedef Return (Klass::*method_type)() const;
+ method_type method;
+ method_pointer(method_type M) : method(M) { }
+ void operator()(generic::const_object object, typename Registry::vector_type &stack) const
+ {
+ Registry &reg = static_cast<Registry &>(object.get_registry());
+ (reg.const_deref<Klass>(object).*method)();
+ }
+ };
+
+ //----------------------------------------------------------- arity = 1
+ template <class Args>
+ struct method_pointerBase1 : method_pointerBase0
+ {
+ typedef typename boost::mpl::at_c<Args, 0>::type A0;
+ typedef typename detail::base_type<A0>::type P0;
+ //typedef Pointer<B0> P0;
+ template <class OI>
+ void AddArgs(OI P)
+ {
+ method_pointerBase0::AddArgs(P);
+ *P++ = type::make_specifier<A0>();
+ }
+ };
+ template <class Registry, class Return, class Klass, class Args>
+ struct method_pointer<Registry, false, false, 1, Return, Klass, Args> : method_pointerBase1<Args>
+ {
+ typedef Return (Klass::*method_type)(A0);
+ method_type method;
+ method_pointer(method_type M) : method(M) { }
+ void operator()(generic::mutable_object object, typename Registry::vector_type &stack) const
+ {
+ Registry &reg = static_cast<Registry &>(object.get_registry());
+ generic::object a0 = stack.pop();
+ stack.push_back(reg.create((reg.deref<Klass>(object).*method)(reg.deref<P0>(a0))));
+ }
+ };
+ template <class Registry, class Return, class Klass, class Args>
+ struct method_pointer<Registry, true, false, 1, Return, Klass, Args> : method_pointerBase1<Args>
+ {
+ typedef Return (Klass::*method_type)(A0) const;
+ method_type method;
+ method_pointer(method_type M) : method(M) { }
+ void operator()(generic::const_object const object, typename Registry::vector_type &stack) const
+ {
+ Registry &reg = static_cast<Registry &>(object.get_registry());
+ generic::object a0 = stack.pop();
+ stack.push_back(reg.create((reg.const_deref<Klass>(object).*method)(reg.deref<P0>(a0))));
+ }
+ };
+ template <class Registry, class Return, class Klass, class Args>
+ struct method_pointer<Registry, false, true, 1, Return, Klass, Args> : method_pointerBase1<Args>
+ {
+ typedef Return (Klass::*method_type)(A0);
+ method_type method;
+ method_pointer(method_type M) : method(M) { }
+ void operator()(generic::object object, typename Registry::vector_type &stack) const
+ {
+ Registry &reg = static_cast<Registry &>(object.get_registry());
+ generic::object a0 = stack.pop();
+ (reg.const_deref<Klass>(object).*method)(reg.deref<P0>(a0))
+ }
+ };
+ template <class Registry, class Return, class Klass, class Args>
+ struct method_pointer<Registry, true, true, 1, Return, Klass, Args> : method_pointerBase1<Args>
+ {
+ typedef Return (Klass::*method_type)(A0) const;
+ method_type method;
+ method_pointer(method_type M) : method(M) { }
+ void operator()(generic::const_object const object, typename Registry::vector_type &stack) const
+ {
+ Registry &reg = static_cast<Registry &>(object.get_registry());
+ generic::object a0 = stack.pop();
+ (reg.const_deref<Klass>(object).*method)(reg.deref<P0>(a0))
+ }
+ };
+
+ /*
+ //----------------------------------------------------------- arity = 2
+ template <class Args>
+ struct method_pointerBase2 : method_pointerBase1<Args>
+ {
+ typedef typename boost::mpl::at_c<Args, 1>::type A1;
+ typedef typename BaseType<A1>::Type B1;
+ typedef Pointer<B1> P1;
+ template <class OI>
+ void AddArgs(OI P)
+ {
+ method_pointerBase1<Args>::AddArgs(P);
+ *P++ = Type::MakeType<A1>::Create();
+ }
+ };
+ template <class Return, class Klass, class Args>
+ struct method_pointer<false, false, 2, Return, Klass, Args> : method_pointerBase2<Args>
+ {
+ typedef Return (Klass::*method_type)(A0,A1);
+ method_type method;
+ method_pointer(method_type M) : method(M) { }
+ void operator()(generic::object &object, typename Registry::vector_type &stack) const
+ {
+ P1 a1 = stack.pop();
+ P0 a0 = stack.pop();
+ stack.push_back(object.New((Deref<Klass>(object).*method)(*a0, *a1)));
+ }
+ };
+ template <class Return, class Klass, class Args>
+ struct method_pointer<true, false, 2, Return, Klass, Args> : method_pointerBase2<Args>
+ {
+ typedef Return (Klass::*method_type)(A0,A1) const;
+ method_type method;
+ method_pointer(method_type M) : method(M) { }
+ void operator()(generic::object const &object, typename Registry::vector_type &stack) const
+ {
+ P1 a1 = stack.pop();
+ P0 a0 = stack.pop();
+ stack.push_back(object.New((Deref<Klass>(object).*method)(*a0, *a1)));
+ }
+ };
+ template <class Return, class Klass, class Args>
+ struct method_pointer<false, true, 2, Return, Klass, Args> : method_pointerBase2<Args>
+ {
+ typedef Return (Klass::*method_type)(A0,A1);
+ method_type method;
+ method_pointer(method_type M) : method(M) { }
+ void operator()(generic::object &object, typename Registry::vector_type &stack) const
+ {
+ P1 a1 = stack.pop();
+ P0 a0 = stack.pop();
+ (Deref<Klass>(object).*method)(*a0, *a1);
+ }
+ };
+ template <class Return, class Klass, class Args>
+ struct method_pointer<true, true, 2, Return, Klass, Args> : method_pointerBase2<Args>
+ {
+ typedef Return (Klass::*method_type)(A0, A1) const;
+ method_type method;
+ method_pointer(method_type M) : method(M) { }
+ void operator()(generic::object const &object, typename Registry::vector_type &stack) const
+ {
+ P1 a1 = stack.pop();
+ P0 a0 = stack.pop();
+ (Deref<Klass>(object).*method)(*a0, *a1);
+ }
+ };
+ //----------------------------------------------------------- arity = 3
+ template <class Args>
+ struct method_pointerBase3 : method_pointerBase2<Args>
+ {
+ typedef typename boost::mpl::at_c<Args, 2>::type A2;
+ typedef typename BaseType<A2>::Type B2;
+ typedef Pointer<B2> P2;
+ template <class OI>
+ void AddArgs(OI P)
+ {
+ method_pointerBase2<Args>::AddArgs(P);
+ *P++ = Type::MakeType<A2>::Create();
+ }
+ };
+ template <class Return, class Klass, class Args>
+ struct method_pointer<false, false, 3, Return, Klass, Args> : method_pointerBase3<Args>
+ {
+ typedef Return (Klass::*method_type)(A0,A1,A2);
+ method_type method;
+ method_pointer(method_type M) : method(M) { }
+ void operator()(generic::object &object, typename Registry::vector_type &stack) const
+ {
+ P2 a2 = stack.pop();
+ P1 a1 = stack.pop();
+ P0 a0 = stack.pop();
+ stack.push_back(object.New((Deref<Klass>(object).*method)(*a0, *a1, *a2)));
+ }
+ };
+ template <class Return, class Klass, class Args>
+ struct method_pointer<true, false, 3, Return, Klass, Args> : method_pointerBase3<Args>
+ {
+ typedef Return (Klass::*method_type)(A0,A1,A2) const;
+ method_type method;
+ method_pointer(method_type M) : method(M) { }
+ void operator()(generic::object const &object, typename Registry::vector_type &stack) const
+ {
+ P2 a2 = stack.pop();
+ P1 a1 = stack.pop();
+ P0 a0 = stack.pop();
+ stack.push_back(object.New((Deref<Klass>(object).*method)(*a0, *a1, *a2)));
+ }
+ };
+ template <class Return, class Klass, class Args>
+ struct method_pointer<false, true, 3, Return, Klass, Args> : method_pointerBase3<Args>
+ {
+ typedef Return (Klass::*method_type)(A0,A1,A2);
+ method_type method;
+ method_pointer(method_type M) : method(M) { }
+ void operator()(generic::object &object, typename Registry::vector_type &stack) const
+ {
+ P2 a2 = stack.pop();
+ P1 a1 = stack.pop();
+ P0 a0 = stack.pop();
+ (Deref<Klass>(object).*method)(*a0, *a1, *a2);
+ }
+ };
+ template <class Return, class Klass, class Args>
+ struct method_pointer<true, true, 3, Return, Klass, Args> : method_pointerBase3<Args>
+ {
+ typedef Return (Klass::*method_type)(A0, A1,A2) const;
+ method_type method;
+ method_pointer(method_type M) : method(M) { }
+ void operator()(generic::object const &object, typename Registry::vector_type &stack) const
+ {
+ P2 a2 = stack.pop();
+ P1 a1 = stack.pop();
+ P0 a0 = stack.pop();
+ (Deref<Klass>(object).*method)(*a0, *a1, *a2);
+ }
+ };
+
+ */
+ template <class Reg, class Rty, class Klass, class Args, bool Konst>
+ struct make_method_pointer
+ {
+ typedef method_pointer<Reg, Konst, boost::is_same<void, Rty>::value, boost::mpl::size<Args>::value, Rty, Klass, Args> type;
+ };
 }
 
 BOOST_OM_END

Modified: sandbox/monotonic/boost/object_model/dictionary.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/dictionary.hpp (original)
+++ sandbox/monotonic/boost/object_model/dictionary.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -19,36 +19,36 @@
 template <class Traits>
 struct dictionary
 {
- typedef typename Traits::label_type label_type;
+ typedef typename Traits::label_type label_type;
 
- typedef std::map<
- label_type
- , generic::object
- , std::less<label_type>
- , typename Traits::allocator_type
- > contents_type;
+ typedef std::map<
+ label_type
+ , generic::object
+ , std::less<label_type>
+ , typename Traits::allocator_type
+ > contents_type;
 
 private:
- contents_type contents;
+ contents_type contents;
 
 public:
- void set(label_type const &name, generic::object const &obj)
- {
- contents[name] = obj;
- }
-
- generic::object get(label_type const &name) const
- {
- contents_type::const_iterator iter = contents.find(name);
- if (iter == contents.end())
- return null_object;
- return iter->second;
- }
-
- bool has(label_type const &name) const
- {
- return contents.find(name) != contents.end();
- }
+ void set(label_type const &name, generic::object const &obj)
+ {
+ contents[name] = obj;
+ }
+
+ generic::object get(label_type const &name) const
+ {
+ contents_type::const_iterator iter = contents.find(name);
+ if (iter == contents.end())
+ return null_object;
+ return iter->second;
+ }
+
+ bool has(label_type const &name) const
+ {
+ return contents.find(name) != contents.end();
+ }
 };
 
 BOOST_OM_END

Modified: sandbox/monotonic/boost/object_model/forward_declarations.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/forward_declarations.hpp (original)
+++ sandbox/monotonic/boost/object_model/forward_declarations.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -16,14 +16,14 @@
 
 namespace type
 {
- /// traits for a given type
- template <class T>
- struct traits;
+ /// traits for a given type
+ template <class T>
+ struct traits;
 
- /// a type number
- struct number;
+ /// a type number
+ struct number;
 
- struct any;
+ struct any;
 }
 
 /// a unique identifier of an object
@@ -40,40 +40,40 @@
 /// generic bases for type-specific derived types
 namespace generic
 {
- struct base;
+ struct base;
 
- struct object_base;
+ struct object_base;
 
- struct const_object;
+ struct const_object;
 
- struct mutable_object;
+ struct mutable_object;
 
- struct object;
+ struct object;
 
- /// common for all const storage for an instance
- template <class Traits>
- struct const_storage;
+ /// common for all const storage for an instance
+ template <class Traits>
+ struct const_storage;
 
- /// common for all storage for an instance
- template <class Traits>
- struct storage;
+ /// common for all storage for an instance
+ template <class Traits>
+ struct storage;
 
- /// common for types that have a `self` pointer
- struct reflected;
+ /// common for types that have a `self` pointer
+ struct reflected;
 
- /// common for a all methods
- template <class Traits>
- struct method;
+ /// common for a all methods
+ template <class Traits>
+ struct method;
 
- /// common for all class properties
- struct property;
+ /// common for all class properties
+ struct property;
 
- /// common for all classes
- //template <class Label>
- struct klass;
+ /// common for all classes
+ //template <class Label>
+ struct klass;
 
- //template <class Label>
- struct registry;
+ //template <class Label>
+ struct registry;
 }
 
 template <class T = type::any>
@@ -139,12 +139,12 @@
 /// traits type to control how the system works, and what data-types to use for various
 /// key components
 template <
- class Alloc = default_allocator // allocator to use for everything
- , class Char = char // default char type
- , class ChTr = std::char_traits<Char> // char traits
- , class Str = string<Alloc, Char, ChTr> // string type to use
- , class Label = label<Str> // label type. used to name sub-objects
- , class Ident = label<Str> // identifier. used to access fields and methods
+ class Alloc = default_allocator // allocator to use for everything
+ , class Char = char // default char type
+ , class ChTr = std::char_traits<Char> // char traits
+ , class Str = string<Alloc, Char, ChTr> // string type to use
+ , class Label = label<Str> // label type. used to name sub-objects
+ , class Ident = label<Str> // identifier. used to access fields and methods
>
 struct system_traits;
 
@@ -154,21 +154,21 @@
 
 namespace containers
 {
- /// an array of objects given an allocator
- template <class Al>
- struct vector;
-
- /// an list of objects given an allocator
- template <class Al>
- struct list;
-
- /// an map of objects to objects given an allocator
- template <class Al>
- struct map;
-
- /// an set of objects given an allocator
- template <class Al>
- struct set;
+ /// an array of objects given an allocator
+ template <class Al>
+ struct vector;
+
+ /// an list of objects given an allocator
+ template <class Al>
+ struct list;
+
+ /// an map of objects to objects given an allocator
+ template <class Al>
+ struct map;
+
+ /// an set of objects given an allocator
+ template <class Al>
+ struct set;
 
 }
 

Modified: sandbox/monotonic/boost/object_model/generic/base.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/generic/base.hpp (original)
+++ sandbox/monotonic/boost/object_model/generic/base.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -16,17 +16,17 @@
 
 namespace generic
 {
- /// common to all other base structures in namespace generic
- struct base
- {
- virtual ~base() { }
- };
-
- /// common to all other base structures in namespace generic
- struct noncopyable_base : noncopyable
- {
- virtual ~noncopyable_base() { }
- };
+ /// common to all other base structures in namespace generic
+ struct base
+ {
+ virtual ~base() { }
+ };
+
+ /// common to all other base structures in namespace generic
+ struct noncopyable_base : noncopyable
+ {
+ virtual ~noncopyable_base() { }
+ };
 }
 
 BOOST_OM_END

Modified: sandbox/monotonic/boost/object_model/generic/class.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/generic/class.hpp (original)
+++ sandbox/monotonic/boost/object_model/generic/class.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -20,29 +20,29 @@
 
 namespace generic
 {
- typedef const char *class_name;
+ typedef const char *class_name;
 
- struct klass : base
- {
- private:
- type::number type_number;
- class_name name;
+ struct klass : base
+ {
+ private:
+ type::number type_number;
+ class_name name;
 
- public:
- klass(class_name ident, type::number num)
- : type_number(num), name(ident) { }
+ public:
+ klass(class_name ident, type::number num)
+ : type_number(num), name(ident) { }
 
- type::number get_type_number() const { return type_number; }
- class_name get_name() const { return name; }
+ type::number get_type_number() const { return type_number; }
+ class_name get_name() const { return name; }
 
- virtual object &create() const = 0;
- virtual void destroy(object &) const = 0;
+ virtual object &create() const = 0;
+ virtual void destroy(object &) const = 0;
 
- //virtual bool has_method(object &) const = 0;
+ //virtual bool has_method(object &) const = 0;
 
- //virtual const_object get_property(const label&, const_object &owner) const = 0;
- //virtual object get_property(const label&, object &owner) const = 0;
- };
+ //virtual const_object get_property(const label&, const_object &owner) const = 0;
+ //virtual object get_property(const label&, object &owner) const = 0;
+ };
 }
 
 BOOST_OM_END

Modified: sandbox/monotonic/boost/object_model/generic/method.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/generic/method.hpp (original)
+++ sandbox/monotonic/boost/object_model/generic/method.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -18,25 +18,25 @@
 
 namespace generic
 {
- /// common base for all specific methods
- template <class Registry>
- struct method
- {
- private:
- typename Registry::label_type name;
- type::signature sig;
-
- public:
-
- virtual void invoke(object &servant, typename Registry::vector_type &args) const = 0;
-
- template <class Traits>
- typename Traits::string_type to_string(const Registry &reg) const
- {
- typename Traits::string_type s;
- return s;
- }
- };
+ /// common base for all specific methods
+ template <class Registry>
+ struct method
+ {
+ private:
+ typename Registry::label_type name;
+ type::signature sig;
+
+ public:
+
+ virtual void invoke(object &servant, typename Registry::vector_type &args) const = 0;
+
+ template <class Traits>
+ typename Traits::string_type to_string(const Registry &reg) const
+ {
+ typename Traits::string_type s;
+ return s;
+ }
+ };
 }
 
 BOOST_OM_END

Modified: sandbox/monotonic/boost/object_model/generic/object.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/generic/object.hpp (original)
+++ sandbox/monotonic/boost/object_model/generic/object.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -20,95 +20,95 @@
 
 namespace generic
 {
- struct object_base
- {
- protected:
- registry *reg;
- klass const *type;
- handle number;
-
- object_base();
- object_base(const object_base&);
-
- template <class T, class Tr> friend struct object_model::klass;
-
- void construct(registry &, klass const &, handle);
- object_base &get_storage();
-
- public:
- klass const &get_class() const;
- type::number get_type_number() const;
- registry &get_registry() const;
- handle get_handle() const;
-
- const object_base &get_storage() const;
- bool exists() const;
-
- template <class T>
- bool is_type() const
- {
- return get_type_number() == type::traits<T>::type_number;
- }
-
- //template <class Label>
- //void set(Label const &name, object const &obj)
- //{
- // set_fun(*this, name, obj);
- //}
-
- //template <class Label>
- //object_base get(Label const &name) const
- //{
- // return set_fun(*this, name);
- //}
- };
-
- struct const_object : object_base
- {
-
- protected:
-
- public:
-// const_object();
- //const_object(const const_storage &);
- //const_object(const const_object &);
- //const_object(const object &);
- //const_object &operator=(const const_object &);
-
- };
-
- // can be const or mutable
- struct object : const_object
- {
- private:
- bool konst;
-
- public:
- object();
- object(const const_object&);
- object(const mutable_object&);
-// object(const object&);
-// object(const storage &);
-// object(const const_storage &);
-
- object &operator=(const const_object&);
- object &operator=(const mutable_object&);
-// object &operator=(const object&);
-
- bool is_const() const { return konst; }
- object_base &get_storage();
- const object_base &get_storage() const;
- };
-
- struct mutable_object : const_object
- {
- mutable_object() { }
- mutable_object(const mutable_object &obj) : const_object(obj) { }
- //mutable_object(const object_base &obj) : const_object(obj) { }
- mutable_object(const object &obj) : const_object(obj) { }
+ struct object_base
+ {
+ protected:
+ registry *reg;
+ klass const *type;
+ handle number;
+
+ object_base();
+ object_base(const object_base&);
+
+ template <class T, class Tr> friend struct object_model::klass;
+
+ void construct(registry &, klass const &, handle);
+ object_base &get_storage();
+
+ public:
+ klass const &get_class() const;
+ type::number get_type_number() const;
+ registry &get_registry() const;
+ handle get_handle() const;
+
+ const object_base &get_storage() const;
+ bool exists() const;
+
+ template <class T>
+ bool is_type() const
+ {
+ return get_type_number() == type::traits<T>::type_number;
+ }
+
+ //template <class Label>
+ //void set(Label const &name, object const &obj)
+ //{
+ // set_fun(*this, name, obj);
+ //}
+
+ //template <class Label>
+ //object_base get(Label const &name) const
+ //{
+ // return set_fun(*this, name);
+ //}
+ };
+
+ struct const_object : object_base
+ {
+
+ protected:
+
+ public:
+// const_object();
+ //const_object(const const_storage &);
+ //const_object(const const_object &);
+ //const_object(const object &);
+ //const_object &operator=(const const_object &);
+
+ };
+
+ // can be const or mutable
+ struct object : const_object
+ {
+ private:
+ bool konst;
+
+ public:
+ object();
+ object(const const_object&);
+ object(const mutable_object&);
+// object(const object&);
+// object(const storage &);
+// object(const const_storage &);
+
+ object &operator=(const const_object&);
+ object &operator=(const mutable_object&);
+// object &operator=(const object&);
+
+ bool is_const() const { return konst; }
+ object_base &get_storage();
+ const object_base &get_storage() const;
+ };
+
+ struct mutable_object : const_object
+ {
+ mutable_object() { }
+ mutable_object(const mutable_object &obj) : const_object(obj) { }
+ //mutable_object(const object_base &obj) : const_object(obj) { }
+ mutable_object(const object &obj) : const_object(obj) { }
 
- object_base &get_storage();
- };
+ object_base &get_storage();
+ };
 
 }
 

Modified: sandbox/monotonic/boost/object_model/generic/registry.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/generic/registry.hpp (original)
+++ sandbox/monotonic/boost/object_model/generic/registry.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -18,17 +18,17 @@
 
 namespace generic
 {
- struct registry : base
- {
- public:
+ struct registry : base
+ {
+ public:
 
- virtual handle get_next_handle() = 0;
- virtual klass const *get_class(type::number) const = 0;
- virtual bool exists(handle) const = 0;
+ virtual handle get_next_handle() = 0;
+ virtual klass const *get_class(type::number) const = 0;
+ virtual bool exists(handle) const = 0;
 
- virtual object_base &get_storage(handle) const = 0;
+ virtual object_base &get_storage(handle) const = 0;
 
- };
+ };
 }
 
 BOOST_OM_END

Modified: sandbox/monotonic/boost/object_model/generic/storage.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/generic/storage.hpp (original)
+++ sandbox/monotonic/boost/object_model/generic/storage.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -16,35 +16,35 @@
 
 namespace generic
 {
- template <class Traits>
- struct const_storage : object
- {
- typedef dictionary<Traits> dictionary_type;
- typedef typename dictionary_type::label_type label_type;
-
- protected:
- dictionary_type dict;
-
- public:
- void set(label_type const &name, generic::object const &obj)
- {
- dict.set(name, obj);
- }
- generic::object get(label_type const &name) const
- {
- return dict.get(name);
- }
- bool has(label_type const &name) const
- {
- return dict.has(name);
- }
- };
-
- template <class Traits>
- struct storage : const_storage<Traits>
- {
+ template <class Traits>
+ struct const_storage : object
+ {
+ typedef dictionary<Traits> dictionary_type;
+ typedef typename dictionary_type::label_type label_type;
+
+ protected:
+ dictionary_type dict;
+
+ public:
+ void set(label_type const &name, generic::object const &obj)
+ {
+ dict.set(name, obj);
+ }
+ generic::object get(label_type const &name) const
+ {
+ return dict.get(name);
+ }
+ bool has(label_type const &name) const
+ {
+ return dict.has(name);
+ }
+ };
+
+ template <class Traits>
+ struct storage : const_storage<Traits>
+ {
 
- };
+ };
 }
 
 BOOST_OM_END

Modified: sandbox/monotonic/boost/object_model/handle.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/handle.hpp (original)
+++ sandbox/monotonic/boost/object_model/handle.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -17,18 +17,18 @@
 /// a handle is a numeric identifier for a system object
 struct handle
 {
- typedef unsigned value_type;
+ typedef unsigned value_type;
 
 private:
- value_type value;
+ value_type value;
 
 public:
- handle() : value(0) {}
- handle(value_type val) : value(val) { }
- value_type get_value() const { return value; }
+ handle() : value(0) {}
+ handle(value_type val) : value(val) { }
+ value_type get_value() const { return value; }
 
- friend bool operator==(handle a, handle b) { return a.value == b.value; }
- friend bool operator<(handle a, handle b) { return a.value < b.value; }
+ friend bool operator==(handle a, handle b) { return a.value == b.value; }
+ friend bool operator<(handle a, handle b) { return a.value < b.value; }
 };
 
 BOOST_OM_END
@@ -38,10 +38,10 @@
 template <>
 struct hash<BOOST_OBJECT_MODEL_NAMESPACE(handle)>
 {
- size_t operator()(BOOST_OBJECT_MODEL_NAMESPACE(handle) num) const
- {
- return num.get_value();
- }
+ size_t operator()(BOOST_OBJECT_MODEL_NAMESPACE(handle) num) const
+ {
+ return num.get_value();
+ }
 };
 
 BOOST_END

Modified: sandbox/monotonic/boost/object_model/label.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/label.hpp (original)
+++ sandbox/monotonic/boost/object_model/label.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -20,44 +20,44 @@
 template <class String>
 struct label
 {
- typedef String string_type;
- typedef typename String::allocator_type allocator_type;
- typedef typename string_type::value_type char_type;
+ typedef String string_type;
+ typedef typename String::allocator_type allocator_type;
+ typedef typename string_type::value_type char_type;
 
 private:
- string_type value;
+ string_type value;
 
 public:
- label() { }
- label(const char_type *text)
- {
- from_string(text);
- }
- label(const string_type &text)
- {
- from_string(text);
- }
+ label() { }
+ label(const char_type *text)
+ {
+ from_string(text);
+ }
+ label(const string_type &text)
+ {
+ from_string(text);
+ }
 
- const string_type &to_string() const { return value; }
+ const string_type &to_string() const { return value; }
 
- friend bool operator==(label const &a, label const &b) { return a.value == b.value; }
- friend bool operator<(label const &a, label const &b) { return a.value < b.value; }
+ friend bool operator==(label const &a, label const &b) { return a.value == b.value; }
+ friend bool operator<(label const &a, label const &b) { return a.value < b.value; }
 
 private:
- void from_string(const string_type &text)
- {
- from_string(text.c_str());
- }
- void from_string(const char_type *text)
- {
- value = text;
- }
+ void from_string(const string_type &text)
+ {
+ from_string(text.c_str());
+ }
+ void from_string(const char_type *text)
+ {
+ value = text;
+ }
 };
 
 template <class Al, class Ch, class Tr, class String>
 string_stream<Al,Ch,Tr> &operator<<(string_stream<Al,Ch,Tr> &stream, const label<String> &val)
 {
- return stream << val.to_string();
+ return stream << val.to_string();
 }
 
 BOOST_OM_END
@@ -67,10 +67,10 @@
 template <class Str>
 struct hash<boost::BOOST_OBJECT_MODEL_NAMESPACE_NAME::label<Str> >
 {
- size_t operator()(const boost::BOOST_OBJECT_MODEL_NAMESPACE_NAME::label<Str> &ident) const
- {
- return hash<const typename Str::char_type *>(ident.to_string().c_str());
- }
+ size_t operator()(const boost::BOOST_OBJECT_MODEL_NAMESPACE_NAME::label<Str> &ident) const
+ {
+ return hash<const typename Str::char_type *>(ident.to_string().c_str());
+ }
 };
 
 BOOST_END

Modified: sandbox/monotonic/boost/object_model/method.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/method.hpp (original)
+++ sandbox/monotonic/boost/object_model/method.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -16,27 +16,27 @@
 BOOST_OM_BEGIN
 
 template <
- class Reg // the registry type
- , class Rty // return type
- , class Klass // servant type
- , class Args // argument list
- , bool Konst // constness
+ class Reg // the registry type
+ , class Rty // return type
+ , class Klass // servant type
+ , class Args // argument list
+ , bool Konst // constness
>
 struct method : generic::method<Reg>, detail::make_method_pointer<Reg, Rty, Klass, Args, Konst>::type
 {
- typedef typename detail::make_method_pointer<Reg, Rty, Klass, Args, Konst>::type Parent;
- method(typename Parent::method_type M) : Parent(M)
- {
- //signature.return_type = Type::MakeType<Rty>::Create();//Type::Traits<typename BaseType<Rty>::Type>::TypeNumber;
- //signature.class_type = Type::Traits<Klass>::TypeNumber;
- //signature.konst = Konst;
- //Parent::AddArgs(std::back_inserter(signature.arguments));
-
- }
- void invoke(generic::object &servant, typename Reg::vector_type &stack) const
- {
- (*this)(servant, stack);
- }
+ typedef typename detail::make_method_pointer<Reg, Rty, Klass, Args, Konst>::type Parent;
+ method(typename Parent::method_type M) : Parent(M)
+ {
+ //signature.return_type = Type::MakeType<Rty>::Create();//Type::Traits<typename BaseType<Rty>::Type>::TypeNumber;
+ //signature.class_type = Type::Traits<Klass>::TypeNumber;
+ //signature.konst = Konst;
+ //Parent::AddArgs(std::back_inserter(signature.arguments));
+
+ }
+ void invoke(generic::object &servant, typename Reg::vector_type &stack) const
+ {
+ (*this)(servant, stack);
+ }
 };
 
 BOOST_OM_END

Modified: sandbox/monotonic/boost/object_model/object.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/object.hpp (original)
+++ sandbox/monotonic/boost/object_model/object.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -19,106 +19,106 @@
 template <>
 struct object<type::any> : generic::object
 {
- object()
- {
- }
-
- template <class Other>
- object(object<Other> const &other) : generic::object(other)
- {
- }
- object(const generic::object &obj) : generic::object(obj)
- {
- }
- object& operator=(object const &other)
- {
- generic::object::operator=(other);
- return *this;
- }
+ object()
+ {
+ }
+
+ template <class Other>
+ object(object<Other> const &other) : generic::object(other)
+ {
+ }
+ object(const generic::object &obj) : generic::object(obj)
+ {
+ }
+ object& operator=(object const &other)
+ {
+ generic::object::operator=(other);
+ return *this;
+ }
 };
 
 /// work in progress... would like (not need) some way to allow free-standing
 /// object<T>'s to be able to dereference themselves without having the owning registry
 struct impl
 {
- struct abstract_object
- {
- // go through the registry to get to the storage base
- virtual generic::object_base &deref() = 0;
- };
+ struct abstract_object
+ {
+ // go through the registry to get to the storage base
+ virtual generic::object_base &deref() = 0;
+ };
 
 
- template <class Derived, class T, class Reg>
- struct object_base
- {
+ template <class Derived, class T, class Reg>
+ struct object_base
+ {
 
- };
+ };
 };
 
 template <class T>//, class Reg = type::none>
 struct object : generic::object// : impl::object_base<object<T,Reg>, T, Reg>
 {
- typedef type::traits<T> traits;
- //scoped_ptr<impl::abstract_object<Reg> > ptr;
- //impl::abstract_object<Reg> *ptr;
+ typedef type::traits<T> traits;
+ //scoped_ptr<impl::abstract_object<Reg> > ptr;
+ //impl::abstract_object<Reg> *ptr;
 
- typedef typename traits::reference_type (*deref_fun)(generic::object &);
- typedef typename traits::const_reference_type (*const_deref_fun)(const generic::object &);
+ typedef typename traits::reference_type (*deref_fun)(generic::object &);
+ typedef typename traits::const_reference_type (*const_deref_fun)(const generic::object &);
 
 private:
- deref_fun deref;
- const_deref_fun const_deref;
+ deref_fun deref;
+ const_deref_fun const_deref;
 
 public:
- object() : deref(0), const_deref(0) {}
+ object() : deref(0), const_deref(0) {}
 
- object(const object<type::any> &obj)
- {
- *this = obj;
- }
-
- object(const generic::object &obj, deref_fun d, const_deref_fun c)
- : deref(d), const_deref(c)
- {
- *this = obj;
- }
-
- object& operator=(object const &other)
- {
- generic::object::operator=(other);
- return *this;
- }
-
- object& operator=(object<type::any> const &other)
- {
- if (!other.is_type<T>())
- throw type_mismatch();
- generic::object::operator=(other);
- return *this;
- }
-
- typename traits::reference_type get_reference()
- {
- if (!deref)
- throw empty_object();
- return deref(*this);
- }
-
- typename traits::reference_type operator*()
- {
- return get_reference();
- }
-
- typename traits::pointer_type operator->()
- {
- return &get_reference();
- }
-
- template <class Label>
- void set(const Label &label, generic::object obj)
- {
- //impl->setter(*this, label, obj);
- }
+ object(const object<type::any> &obj)
+ {
+ *this = obj;
+ }
+
+ object(const generic::object &obj, deref_fun d, const_deref_fun c)
+ : deref(d), const_deref(c)
+ {
+ *this = obj;
+ }
+
+ object& operator=(object const &other)
+ {
+ generic::object::operator=(other);
+ return *this;
+ }
+
+ object& operator=(object<type::any> const &other)
+ {
+ if (!other.is_type<T>())
+ throw type_mismatch();
+ generic::object::operator=(other);
+ return *this;
+ }
+
+ typename traits::reference_type get_reference()
+ {
+ if (!deref)
+ throw empty_object();
+ return deref(*this);
+ }
+
+ typename traits::reference_type operator*()
+ {
+ return get_reference();
+ }
+
+ typename traits::pointer_type operator->()
+ {
+ return &get_reference();
+ }
+
+ template <class Label>
+ void set(const Label &label, generic::object obj)
+ {
+ //impl->setter(*this, label, obj);
+ }
 
 };
 

Modified: sandbox/monotonic/boost/object_model/registry.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/registry.hpp (original)
+++ sandbox/monotonic/boost/object_model/registry.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -30,387 +30,387 @@
 template <class Tr>
 struct registry : generic::registry
 {
- typedef Tr traits, traits_type, system_traits;
- typedef typename traits::allocator_type allocator_type;
- typedef typename traits::char_traits char_traits;
- typedef typename traits::char_type char_type;
- typedef typename traits::string_type string_type;
- typedef typename traits::label_type label_type;
- typedef typename traits::identifier_type identifier_type;
-
- typedef containers::vector<allocator_type> vector_type;
-
- typedef registry<Tr> This, this_type;
-
- template <class T>
- struct rebind_klass
- {
- typedef klass<T, this_type> type;
- };
- template <class T>
- struct rebind_storage
- {
- typedef storage<T, traits_type> type;
- };
+ typedef Tr traits, traits_type, system_traits;
+ typedef typename traits::allocator_type allocator_type;
+ typedef typename traits::char_traits char_traits;
+ typedef typename traits::char_type char_type;
+ typedef typename traits::string_type string_type;
+ typedef typename traits::label_type label_type;
+ typedef typename traits::identifier_type identifier_type;
+
+ typedef containers::vector<allocator_type> vector_type;
+
+ typedef registry<Tr> This, this_type;
+
+ template <class T>
+ struct rebind_klass
+ {
+ typedef klass<T, this_type> type;
+ };
+ template <class T>
+ struct rebind_storage
+ {
+ typedef storage<T, traits_type> type;
+ };
 
 #ifndef BOOST_OBJECT_MODEL_REGISTRY_USE_UNORDERED_MAPS
- typedef std::map<
- handle
- , generic::storage<traits> *
- , std::less<handle>
- , allocator_type
- > instances_type;
-
- typedef std::map<
- type::number
- , detail::klass_base<this_type> const *
- , std::less<type::number>
- , allocator_type
- > classes_type;
+ typedef std::map<
+ handle
+ , generic::storage<traits> *
+ , std::less<handle>
+ , allocator_type
+ > instances_type;
+
+ typedef std::map<
+ type::number
+ , detail::klass_base<this_type> const *
+ , std::less<type::number>
+ , allocator_type
+ > classes_type;
 #else
- typedef boost::unordered_map<
- handle
- , generic::storage<traits> *
- , boost::hash<handle>
- , std::less<handle>
- , allocator_type
- > instances_type;
-
- typedef boost::unordered_map<
- type::number
- , detail::klass_base<this_type> const *
- , boost::hash<type::number>
- , std::less<type::number>
- , allocator_type
- > classes_type;
+ typedef boost::unordered_map<
+ handle
+ , generic::storage<traits> *
+ , boost::hash<handle>
+ , std::less<handle>
+ , allocator_type
+ > instances_type;
+
+ typedef boost::unordered_map<
+ type::number
+ , detail::klass_base<this_type> const *
+ , boost::hash<type::number>
+ , std::less<type::number>
+ , allocator_type
+ > classes_type;
 #endif
 
- template <class T>
- static typename type::traits<T>::reference_type deref(generic::object &object)
- {
- if (!object.is_type<T>())
- throw type_mismatch();
- if (object.is_const())
- throw const_error();
- return static_cast<typename rebind_storage<T>::type &>(object.get_storage()).get_reference();
- }
-
- template <class T>
- static typename type::traits<T>::reference_type deref(generic::mutable_object &object)
- {
- if (!object.is_type<T>())
- throw type_mismatch();
- return static_cast<typename rebind_storage<T>::type &>(object.get_storage()).get_reference();
- }
-
- template <class T>
- static typename type::traits<T>::const_reference_type const_deref(generic::object const &object)
- {
- if (!object.is_type<T>())
- throw type_mismatch();
- return static_cast<const_storage<T, traits_type> const &>(object.get_storage()).get_const_reference();
- }
-
- template <class Ty>
- void set_value(generic::object &obj, const Ty &value)
- {
- deref<Ty>(obj) = value;
- }
- template <class Ty>
- Ty const &get_const_value(generic::object &obj)
- {
- return const_deref<Ty>(obj);
- }
- template <class Ty>
- Ty const &get_value(const generic::const_object &obj)
- {
- return const_deref<Ty>(obj);
- }
- template <class Ty>
- Ty &get_value(generic::mutable_object &obj)
- {
- return deref<Ty>(obj);
- }
- template <class Ty>
- void set_child_value(generic::object &parent, typename traits::label_type const &label, const Ty &value)
- {
- generic::object child = get(parent, label);
- if (!child.exists())
- set(parent, label, create<Ty>(value));
- else
- deref<Ty>(child) = value;
- }
-
- template <class Ty>
- Ty &get_child_value(generic::object &parent, typename traits::label_type const &label)
- {
- generic::object child = get(parent, label);
- if (!child.exists())
- throw empty_object();
- return deref<Ty>(child);
- }
-
- template <class Ty>
- const Ty &get_child_value(const generic::const_object &parent, typename traits::label_type const &label)
- {
- generic::const_object child = get(parent, label);
- if (!child.exists())
- throw empty_object();
- return deref<Ty>(child);
- }
-
- void set_child(generic::object parent, typename traits::label_type const &label, const generic::const_object child)
- {
- generic::storage<traits> &p = get_storage(parent.get_handle());
- generic::const_storage<traits> &q = get_const_storage(child.get_handle());
- p.set(label, q);
- }
-
- generic::mutable_object get_child(const generic::mutable_object parent, typename traits::label_type const &label)
- {
- generic::storage<traits> &p = get_storage(parent.get_handle());
- return p.get(label);
- }
-
- generic::const_object get_const_child(const generic::object &parent, typename traits::label_type const &label)
- {
- const generic::const_storage<traits> &p = get_const_storage(parent.get_handle());
- return p.get(label);
- }
- generic::const_object get_child(const generic::const_object parent, typename traits::label_type const &label)
- {
- return get_const_child(parent);
- }
-
- bool has_child(const generic::const_object parent, typename traits::label_type const &label)
- {
- const generic::const_storage<traits> &p = get_const_storage(parent.get_handle());
- return p.has(label);
- }
-
- bool has_method(const generic::object &obj, typename traits::identifier_type const &ident) const
- {
- return get_method_ptr(obj, ident) != 0;
- }
-
- const generic::method<this_type> &get_method(const generic::object &obj, typename traits::identifier_type const &ident) const
- {
- const generic::method<this_type> *ptr = get_method_ptr(obj, ident);
- if (ptr == 0)
- throw;
- return *ptr;
- }
- const generic::method<this_type> *get_method_ptr(const generic::object &obj, typename traits::identifier_type const &ident) const
- {
- classes_type::const_iterator iter = classes.find(obj.get_type_number());
- if (iter == classes.end())
- return 0;
- return iter->second->get_method(ident);
- }
+ template <class T>
+ static typename type::traits<T>::reference_type deref(generic::object &object)
+ {
+ if (!object.is_type<T>())
+ throw type_mismatch();
+ if (object.is_const())
+ throw const_error();
+ return static_cast<typename rebind_storage<T>::type &>(object.get_storage()).get_reference();
+ }
+
+ template <class T>
+ static typename type::traits<T>::reference_type deref(generic::mutable_object &object)
+ {
+ if (!object.is_type<T>())
+ throw type_mismatch();
+ return static_cast<typename rebind_storage<T>::type &>(object.get_storage()).get_reference();
+ }
+
+ template <class T>
+ static typename type::traits<T>::const_reference_type const_deref(generic::object const &object)
+ {
+ if (!object.is_type<T>())
+ throw type_mismatch();
+ return static_cast<const_storage<T, traits_type> const &>(object.get_storage()).get_const_reference();
+ }
+
+ template <class Ty>
+ void set_value(generic::object &obj, const Ty &value)
+ {
+ deref<Ty>(obj) = value;
+ }
+ template <class Ty>
+ Ty const &get_const_value(generic::object &obj)
+ {
+ return const_deref<Ty>(obj);
+ }
+ template <class Ty>
+ Ty const &get_value(const generic::const_object &obj)
+ {
+ return const_deref<Ty>(obj);
+ }
+ template <class Ty>
+ Ty &get_value(generic::mutable_object &obj)
+ {
+ return deref<Ty>(obj);
+ }
+ template <class Ty>
+ void set_child_value(generic::object &parent, typename traits::label_type const &label, const Ty &value)
+ {
+ generic::object child = get(parent, label);
+ if (!child.exists())
+ set(parent, label, create<Ty>(value));
+ else
+ deref<Ty>(child) = value;
+ }
+
+ template <class Ty>
+ Ty &get_child_value(generic::object &parent, typename traits::label_type const &label)
+ {
+ generic::object child = get(parent, label);
+ if (!child.exists())
+ throw empty_object();
+ return deref<Ty>(child);
+ }
+
+ template <class Ty>
+ const Ty &get_child_value(const generic::const_object &parent, typename traits::label_type const &label)
+ {
+ generic::const_object child = get(parent, label);
+ if (!child.exists())
+ throw empty_object();
+ return deref<Ty>(child);
+ }
+
+ void set_child(generic::object parent, typename traits::label_type const &label, const generic::const_object child)
+ {
+ generic::storage<traits> &p = get_storage(parent.get_handle());
+ generic::const_storage<traits> &q = get_const_storage(child.get_handle());
+ p.set(label, q);
+ }
+
+ generic::mutable_object get_child(const generic::mutable_object parent, typename traits::label_type const &label)
+ {
+ generic::storage<traits> &p = get_storage(parent.get_handle());
+ return p.get(label);
+ }
+
+ generic::const_object get_const_child(const generic::object &parent, typename traits::label_type const &label)
+ {
+ const generic::const_storage<traits> &p = get_const_storage(parent.get_handle());
+ return p.get(label);
+ }
+ generic::const_object get_child(const generic::const_object parent, typename traits::label_type const &label)
+ {
+ return get_const_child(parent);
+ }
+
+ bool has_child(const generic::const_object parent, typename traits::label_type const &label)
+ {
+ const generic::const_storage<traits> &p = get_const_storage(parent.get_handle());
+ return p.has(label);
+ }
+
+ bool has_method(const generic::object &obj, typename traits::identifier_type const &ident) const
+ {
+ return get_method_ptr(obj, ident) != 0;
+ }
+
+ const generic::method<this_type> &get_method(const generic::object &obj, typename traits::identifier_type const &ident) const
+ {
+ const generic::method<this_type> *ptr = get_method_ptr(obj, ident);
+ if (ptr == 0)
+ throw;
+ return *ptr;
+ }
+ const generic::method<this_type> *get_method_ptr(const generic::object &obj, typename traits::identifier_type const &ident) const
+ {
+ classes_type::const_iterator iter = classes.find(obj.get_type_number());
+ if (iter == classes.end())
+ return 0;
+ return iter->second->get_method(ident);
+ }
 protected:
- template <class, class> friend struct klass;
- handle get_next_handle()
- {
- return ++next_handle;
- }
+ template <class, class> friend struct klass;
+ handle get_next_handle()
+ {
+ return ++next_handle;
+ }
 
 private:
- allocator_type allocator;
- instances_type instances;
- classes_type classes;
- handle::value_type next_handle;
+ allocator_type allocator;
+ instances_type instances;
+ classes_type classes;
+ handle::value_type next_handle;
 
 public:
- registry()
- {
- }
- ~registry()
- {
- clear_classes();
- }
- void add_builtins()
- {
- register_class<void>();
- register_class<bool>();
- register_class<int>();
- register_class<float>();
- register_class<vector_type>();
- }
- void clear()
- {
- BOOST_FOREACH(typename instances_type::value_type &val, instances)
- {
- generic::object &obj = *val.second;
- obj.get_class().destroy(obj);
- }
- instances.clear();
- }
- void clear_classes()
- {
- clear();
- BOOST_FOREACH(typename classes_type::value_type &val, classes)
- {
- allocator_destroy_deallocate(const_cast<detail::klass_base<this_type> *>(val.second));
- }
- classes.clear();
- }
-
- void destroy(generic::mutable_object obj)
- {
- instances_type::iterator val = instances.find(obj.get_handle());
- if (val == instances.end())
- {
- return;
- }
- obj.get_class().destroy(*val->second);
- instances.erase(val);
- }
-
- generic::storage<traits> &get_storage(handle h) const
- {
- instances_type::const_iterator iter = instances.find(h);
- if (iter == instances.end())
- throw unknown_handle();
- return *iter->second;
- }
-
- generic::const_storage<traits> get_const_storage(handle h) const
- {
- instances_type::const_iterator iter = instances.find(h);
- if (iter == instances.end())
- throw unknown_handle();
- return *iter->second;
- }
-
- size_t num_classes() const
- {
- return classes.size();
- }
- size_t num_instances() const
- {
- return instances.size();
- }
-
- bool exists(const generic::const_object &obj) const
- {
- return exists(obj.get_handle());
- }
- bool exists(handle h) const
- {
- return instances.find(h) != instances.end();
- }
-
- allocator_type &get_allocator()
- {
- return allocator;
- }
-
- template <class T>
- typename rebind_klass<T>::type *register_class()
- {
- if (has_class<T>())
- return const_cast<klass<T, this_type> * >(get_class<T>());
-
- BOOST_ASSERT(!has_class<T>());
- typedef typename rebind_klass<T>::type class_type;
- class_type *new_class = allocator_create<class_type >(*this);
- classes[new_class->get_type_number()] = new_class;
- BOOST_ASSERT(classes.find(new_class->get_type_number()) != classes.end());
- return new_class;
- }
-
- generic::klass const *get_class(type::number number) const
- {
- classes_type::const_iterator iter = classes.find(number);
- return iter == classes.end() ? 0 : iter->second;
- }
-
- template <class T>
- object<T> create()
- {
- typename rebind_klass<T>::type const *k = get_class<T>();
- if (k == 0)
- throw unknown_type();
- typedef typename rebind_storage<T>::type storage_type;
- storage_type &obj = static_cast<storage_type &>(k->create());
- instances[obj.get_handle()] = &obj;
- return object<T>(obj, &this_type::deref<T>, &this_type::const_deref<T>);
- }
- template <class T>
- object<T> create(T const &init)
- {
- typename rebind_klass<T>::type const *k = get_class<T>();
- if (k == 0)
- throw unknown_type();
- typedef typename rebind_storage<T>::type storage_type;
- storage_type &obj = static_cast<storage_type &>(k->create(init));
- instances[obj.get_handle()] = &obj;
- return object<T>(obj, &this_type::deref<T>, &this_type::const_deref<T>);
- }
-
- template <class T>
- bool has_class() const
- {
- return get_class<T>() != 0;
- }
-
- template <class T>
- typename rebind_klass<T>::type const *get_class() const
- {
- classes_type::const_iterator iter = classes.find(type::traits<T>::type_number);
- if (iter == classes.end())
- return 0;
- return static_cast<typename rebind_klass<T>::type const *>(iter->second);
- }
-
- ///
-
- template <class T>
- T *allocator_allocate()
- {
- typename allocator_type::template rebind<T>::other alloc(allocator);
- return alloc.allocate(1);
- }
-
- template <class T>
- T *allocator_create()
- {
- T *ptr = allocator_allocate<T>();
- new (ptr) T();
- return ptr;
- }
-
- template <class T, class U>
- T *allocator_create(U &init)
- {
- typename allocator_type::template rebind<T>::other alloc(allocator);
- T *ptr = alloc.allocate(1);
- //alloc.construct(ptr, init);
- new (ptr) T(init);
- return ptr;
- }
-
- template <class T>
- void allocator_destroy(T *ptr)
- {
- typename allocator_type::template rebind<T>::other alloc(allocator);
- alloc.destroy(ptr);
- }
-
- template <class T>
- void allocator_deallocate(T *ptr)
- {
- typename allocator_type::template rebind<T>::other alloc(allocator);
- alloc.deallocate(ptr);
- }
-
- template <class T>
- void allocator_destroy_deallocate(T *ptr)
- {
- typename allocator_type::template rebind<T>::other alloc(allocator);
- alloc.destroy(ptr);
- alloc.deallocate(ptr,1);
- }
+ registry()
+ {
+ }
+ ~registry()
+ {
+ clear_classes();
+ }
+ void add_builtins()
+ {
+ register_class<void>();
+ register_class<bool>();
+ register_class<int>();
+ register_class<float>();
+ register_class<vector_type>();
+ }
+ void clear()
+ {
+ BOOST_FOREACH(typename instances_type::value_type &val, instances)
+ {
+ generic::object &obj = *val.second;
+ obj.get_class().destroy(obj);
+ }
+ instances.clear();
+ }
+ void clear_classes()
+ {
+ clear();
+ BOOST_FOREACH(typename classes_type::value_type &val, classes)
+ {
+ allocator_destroy_deallocate(const_cast<detail::klass_base<this_type> *>(val.second));
+ }
+ classes.clear();
+ }
+
+ void destroy(generic::mutable_object obj)
+ {
+ instances_type::iterator val = instances.find(obj.get_handle());
+ if (val == instances.end())
+ {
+ return;
+ }
+ obj.get_class().destroy(*val->second);
+ instances.erase(val);
+ }
+
+ generic::storage<traits> &get_storage(handle h) const
+ {
+ instances_type::const_iterator iter = instances.find(h);
+ if (iter == instances.end())
+ throw unknown_handle();
+ return *iter->second;
+ }
+
+ generic::const_storage<traits> get_const_storage(handle h) const
+ {
+ instances_type::const_iterator iter = instances.find(h);
+ if (iter == instances.end())
+ throw unknown_handle();
+ return *iter->second;
+ }
+
+ size_t num_classes() const
+ {
+ return classes.size();
+ }
+ size_t num_instances() const
+ {
+ return instances.size();
+ }
+
+ bool exists(const generic::const_object &obj) const
+ {
+ return exists(obj.get_handle());
+ }
+ bool exists(handle h) const
+ {
+ return instances.find(h) != instances.end();
+ }
+
+ allocator_type &get_allocator()
+ {
+ return allocator;
+ }
+
+ template <class T>
+ typename rebind_klass<T>::type *register_class()
+ {
+ if (has_class<T>())
+ return const_cast<klass<T, this_type> * >(get_class<T>());
+
+ BOOST_ASSERT(!has_class<T>());
+ typedef typename rebind_klass<T>::type class_type;
+ class_type *new_class = allocator_create<class_type >(*this);
+ classes[new_class->get_type_number()] = new_class;
+ BOOST_ASSERT(classes.find(new_class->get_type_number()) != classes.end());
+ return new_class;
+ }
+
+ generic::klass const *get_class(type::number number) const
+ {
+ classes_type::const_iterator iter = classes.find(number);
+ return iter == classes.end() ? 0 : iter->second;
+ }
+
+ template <class T>
+ object<T> create()
+ {
+ typename rebind_klass<T>::type const *k = get_class<T>();
+ if (k == 0)
+ throw unknown_type();
+ typedef typename rebind_storage<T>::type storage_type;
+ storage_type &obj = static_cast<storage_type &>(k->create());
+ instances[obj.get_handle()] = &obj;
+ return object<T>(obj, &this_type::deref<T>, &this_type::const_deref<T>);
+ }
+ template <class T>
+ object<T> create(T const &init)
+ {
+ typename rebind_klass<T>::type const *k = get_class<T>();
+ if (k == 0)
+ throw unknown_type();
+ typedef typename rebind_storage<T>::type storage_type;
+ storage_type &obj = static_cast<storage_type &>(k->create(init));
+ instances[obj.get_handle()] = &obj;
+ return object<T>(obj, &this_type::deref<T>, &this_type::const_deref<T>);
+ }
+
+ template <class T>
+ bool has_class() const
+ {
+ return get_class<T>() != 0;
+ }
+
+ template <class T>
+ typename rebind_klass<T>::type const *get_class() const
+ {
+ classes_type::const_iterator iter = classes.find(type::traits<T>::type_number);
+ if (iter == classes.end())
+ return 0;
+ return static_cast<typename rebind_klass<T>::type const *>(iter->second);
+ }
+
+ ///
+
+ template <class T>
+ T *allocator_allocate()
+ {
+ typename allocator_type::template rebind<T>::other alloc(allocator);
+ return alloc.allocate(1);
+ }
+
+ template <class T>
+ T *allocator_create()
+ {
+ T *ptr = allocator_allocate<T>();
+ new (ptr) T();
+ return ptr;
+ }
+
+ template <class T, class U>
+ T *allocator_create(U &init)
+ {
+ typename allocator_type::template rebind<T>::other alloc(allocator);
+ T *ptr = alloc.allocate(1);
+ //alloc.construct(ptr, init);
+ new (ptr) T(init);
+ return ptr;
+ }
+
+ template <class T>
+ void allocator_destroy(T *ptr)
+ {
+ typename allocator_type::template rebind<T>::other alloc(allocator);
+ alloc.destroy(ptr);
+ }
+
+ template <class T>
+ void allocator_deallocate(T *ptr)
+ {
+ typename allocator_type::template rebind<T>::other alloc(allocator);
+ alloc.deallocate(ptr);
+ }
+
+ template <class T>
+ void allocator_destroy_deallocate(T *ptr)
+ {
+ typename allocator_type::template rebind<T>::other alloc(allocator);
+ alloc.destroy(ptr);
+ alloc.deallocate(ptr,1);
+ }
 };
 
 BOOST_OM_END

Modified: sandbox/monotonic/boost/object_model/storage.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/storage.hpp (original)
+++ sandbox/monotonic/boost/object_model/storage.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -17,46 +17,46 @@
 template <class T, class Traits>
 struct const_storage : generic::const_storage<Traits>
 {
- typedef Traits system_traits;
- typedef type::traits<T> type_traits;
- typename type_traits::storage_type value;
-
- const_storage() {}
- const_storage(typename type_traits::const_reference_type init) : value(init) { }
- typename type_traits::const_reference_type get_const_reference() const
- {
- return value;
- }
+ typedef Traits system_traits;
+ typedef type::traits<T> type_traits;
+ typename type_traits::storage_type value;
+
+ const_storage() {}
+ const_storage(typename type_traits::const_reference_type init) : value(init) { }
+ typename type_traits::const_reference_type get_const_reference() const
+ {
+ return value;
+ }
 };
 
 template <class T, class Traits>
 struct storage : generic::storage<Traits>
 {
- typedef Traits system_traits;
- typedef type::traits<T> type_traits;
- typename type_traits::storage_type value;
- mutable bool dirty;
-
- storage() : dirty(true) {}
- storage(typename type_traits::const_reference_type init) : value(init), dirty(false) { }
-
- typename type_traits::const_reference_type get_const_reference() const
- {
- return value;
- }
- typename type_traits::reference_type get_reference()
- {
- dirty = true;
- return value;
- }
- bool is_dirty() const
- {
- return dirty;
- }
- void set_clean() const
- {
- dirty = false;
- }
+ typedef Traits system_traits;
+ typedef type::traits<T> type_traits;
+ typename type_traits::storage_type value;
+ mutable bool dirty;
+
+ storage() : dirty(true) {}
+ storage(typename type_traits::const_reference_type init) : value(init), dirty(false) { }
+
+ typename type_traits::const_reference_type get_const_reference() const
+ {
+ return value;
+ }
+ typename type_traits::reference_type get_reference()
+ {
+ dirty = true;
+ return value;
+ }
+ bool is_dirty() const
+ {
+ return dirty;
+ }
+ void set_clean() const
+ {
+ dirty = false;
+ }
 };
 
 BOOST_OM_END

Modified: sandbox/monotonic/boost/object_model/string.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/string.hpp (original)
+++ sandbox/monotonic/boost/object_model/string.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -17,37 +17,37 @@
 template <class Alloc, class Ch, class Tr>
 struct string
 {
- typedef std::basic_string<Ch, Tr, Alloc> implementation;
- typedef typename implementation::value_type value_type;
- typedef typename implementation::iterator iterator;
- typedef typename implementation::const_iterator const_iterator;
- typedef Alloc allocator_type;
+ typedef std::basic_string<Ch, Tr, Alloc> implementation;
+ typedef typename implementation::value_type value_type;
+ typedef typename implementation::iterator iterator;
+ typedef typename implementation::const_iterator const_iterator;
+ typedef Alloc allocator_type;
 
 private:
- implementation impl;
+ implementation impl;
 
 public:
 
- string() { }
- string(const value_type *text) : impl(text) { }
- string &operator=(const value_type *text)
- {
- impl = text;
- return *this;
- }
- const value_type *c_str() const
- {
- return impl.c_str();
- }
-
- friend bool operator==(string const &a, string const &b)
- {
- return a.impl == b.impl;
- }
- friend bool operator<(string const &a, string const &b)
- {
- return a.impl < b.impl;
- }
+ string() { }
+ string(const value_type *text) : impl(text) { }
+ string &operator=(const value_type *text)
+ {
+ impl = text;
+ return *this;
+ }
+ const value_type *c_str() const
+ {
+ return impl.c_str();
+ }
+
+ friend bool operator==(string const &a, string const &b)
+ {
+ return a.impl == b.impl;
+ }
+ friend bool operator<(string const &a, string const &b)
+ {
+ return a.impl < b.impl;
+ }
 };
 
 BOOST_OM_END

Modified: sandbox/monotonic/boost/object_model/string_stream.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/string_stream.hpp (original)
+++ sandbox/monotonic/boost/object_model/string_stream.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -17,23 +17,23 @@
 template <class Alloc = default_allocator, class Ch = char, class Tr = std::char_traits<Ch> >
 struct string_stream
 {
- typedef string<Alloc,Ch,Tr> string_type;
- typedef std::basic_stringstream<Ch, Tr, Alloc> string_stream_type;
+ typedef string<Alloc,Ch,Tr> string_type;
+ typedef std::basic_stringstream<Ch, Tr, Alloc> string_stream_type;
 
 private:
- string_stream_type stream;
+ string_stream_type stream;
 
 public:
- string_type str() const
- {
- return stream.str();
- }
+ string_type str() const
+ {
+ return stream.str();
+ }
 };
 
 template <class Al, class Ch, class Tr, class Ty>
 string_stream<Al,Ch,Tr> &operator<<(string_stream<Al,Ch,Tr> &stream, const Ty &val)
 {
- return stream << val;
+ return stream << val;
 }
 
 BOOST_OM_END

Modified: sandbox/monotonic/boost/object_model/system_traits.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/system_traits.hpp (original)
+++ sandbox/monotonic/boost/object_model/system_traits.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -18,27 +18,27 @@
 
 ///
 template <class Alloc
- , class Char
- , class ChTr
- , class Str
- , class Label
- , class Ident
+ , class Char
+ , class ChTr
+ , class Str
+ , class Label
+ , class Ident
>
 struct system_traits
 {
- typedef Char char_type;
- typedef Alloc allocator_type;
- typedef Str string_type;
- typedef ChTr char_traits;
- typedef Label label_type;
- typedef Ident identifier_type;
- typedef system_traits<Alloc, Char, ChTr, Str, Label, Ident> this_type;
+ typedef Char char_type;
+ typedef Alloc allocator_type;
+ typedef Str string_type;
+ typedef ChTr char_traits;
+ typedef Label label_type;
+ typedef Ident identifier_type;
+ typedef system_traits<Alloc, Char, ChTr, Str, Label, Ident> this_type;
 };
 
 template <class Label, class Al = default_allocator, class Ch = char >
 struct set_label : system_traits<Al, Ch>
 {
- typedef Label label_type;
+ typedef Label label_type;
 };
 
 BOOST_OM_END

Modified: sandbox/monotonic/boost/object_model/type/modifiers.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/type/modifiers.hpp (original)
+++ sandbox/monotonic/boost/object_model/type/modifiers.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -16,29 +16,29 @@
 
 namespace type
 {
- struct modifiers
- {
- typedef std::bitset<3> flags_type;
- typedef unsigned long flags_value;
- enum
- {
- None = 0,
- Const = 1,
- Reference = 2,
- };
- private:
- flags_type flags;
-
- public:
- modifiers() : flags((flags_value)0) { }
- modifiers(flags_value N) : flags(N) { }
-
- bool is_const() const { return flags[Const]; }
- bool is_reference() const { return flags[Reference]; }
- void set_const(bool B = true) { flags[Const] = B; }
- void set_reference(bool B = true) { flags[Reference] = B; }
- void set_const_reference(bool B = true) { set_const(B); set_reference(B); }
- };
+ struct modifiers
+ {
+ typedef std::bitset<3> flags_type;
+ typedef unsigned long flags_value;
+ enum
+ {
+ None = 0,
+ Const = 1,
+ Reference = 2,
+ };
+ private:
+ flags_type flags;
+
+ public:
+ modifiers() : flags((flags_value)0) { }
+ modifiers(flags_value N) : flags(N) { }
+
+ bool is_const() const { return flags[Const]; }
+ bool is_reference() const { return flags[Reference]; }
+ void set_const(bool B = true) { flags[Const] = B; }
+ void set_reference(bool B = true) { flags[Reference] = B; }
+ void set_const_reference(bool B = true) { set_const(B); set_reference(B); }
+ };
 }
 
 BOOST_OM_END

Modified: sandbox/monotonic/boost/object_model/type/number.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/type/number.hpp (original)
+++ sandbox/monotonic/boost/object_model/type/number.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -15,40 +15,40 @@
 
 namespace type
 {
- struct number
- {
- enum builtins
- {
- None,
- Any,
- Void,
-
- Object,
-
- Method,
- Property,
- Class,
-
- Bool,
- Int,
- Float,
- String,
-
- List,
- Vector,
- Map,
- Set,
- };
-
- typedef unsigned short value_type;
- value_type value;
-
- number() : value(0) { }
- number(value_type val) : value(val) { }
-
- friend bool operator==(number a, number b) { return a.value == b.value; }
- friend bool operator<(number a, number b) { return a.value < b.value; }
- };
+ struct number
+ {
+ enum builtins
+ {
+ None,
+ Any,
+ Void,
+
+ Object,
+
+ Method,
+ Property,
+ Class,
+
+ Bool,
+ Int,
+ Float,
+ String,
+
+ List,
+ Vector,
+ Map,
+ Set,
+ };
+
+ typedef unsigned short value_type;
+ value_type value;
+
+ number() : value(0) { }
+ number(value_type val) : value(val) { }
+
+ friend bool operator==(number a, number b) { return a.value == b.value; }
+ friend bool operator<(number a, number b) { return a.value < b.value; }
+ };
 
 }
 
@@ -59,10 +59,10 @@
 template <>
 struct hash<BOOST_OBJECT_MODEL_NAMESPACE(type::number)>
 {
- size_t operator()(BOOST_OBJECT_MODEL_NAMESPACE(type::number) num) const
- {
- return num.value;
- }
+ size_t operator()(BOOST_OBJECT_MODEL_NAMESPACE(type::number) num) const
+ {
+ return num.value;
+ }
 };
 
 BOOST_END

Modified: sandbox/monotonic/boost/object_model/type/signature.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/type/signature.hpp (original)
+++ sandbox/monotonic/boost/object_model/type/signature.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -15,9 +15,9 @@
 
 namespace type
 {
- struct signature
- {
- };
+ struct signature
+ {
+ };
 }
 
 BOOST_OM_END

Modified: sandbox/monotonic/boost/object_model/type/specifier.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/type/specifier.hpp (original)
+++ sandbox/monotonic/boost/object_model/type/specifier.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -19,48 +19,48 @@
 
 namespace type
 {
- struct specifier : modifiers
- {
- number type_number;
-
- specifier(number N = number::None, modifiers M = modifiers()) : modifiers(M), type_number(N) { }
-
- number get_number() const { return type_number; }
-
- template <class Alloc>
- string<Alloc> to_string(const registry<Alloc> &reg) const
- {
- string_stream<Alloc> stream;
- generic::klass const *k = reg.get_class(type_number);
- if (k == 0)
- stream << "[type_number: " << type_number.value << "]";
- else
- stream << k->get_name();
- if (is_const())
- stream << " const";
- if (is_reference())
- stream << " &";
- return stream.str();
- }
- };
-
- template <class T>
- struct is_const : mpl::true_ { };
-
- template <class T>
- struct is_const<const T> : mpl::true_ { };
-
- template <class T>
- struct is_const<const T&> : mpl::true_ { };
-
- template <class T>
- specifier make_specifier()
- {
- modifiers mods;
- mods.set_const(is_const<T>::value); // what is wrong with boost::is_const<T> ??
- mods.set_reference(boost::is_reference<T>::value);
- return specifier();//(traits<typename base_type<T>::Type>::type_number, mods);
- };
+ struct specifier : modifiers
+ {
+ number type_number;
+
+ specifier(number N = number::None, modifiers M = modifiers()) : modifiers(M), type_number(N) { }
+
+ number get_number() const { return type_number; }
+
+ template <class Alloc>
+ string<Alloc> to_string(const registry<Alloc> &reg) const
+ {
+ string_stream<Alloc> stream;
+ generic::klass const *k = reg.get_class(type_number);
+ if (k == 0)
+ stream << "[type_number: " << type_number.value << "]";
+ else
+ stream << k->get_name();
+ if (is_const())
+ stream << " const";
+ if (is_reference())
+ stream << " &";
+ return stream.str();
+ }
+ };
+
+ template <class T>
+ struct is_const : mpl::true_ { };
+
+ template <class T>
+ struct is_const<const T> : mpl::true_ { };
+
+ template <class T>
+ struct is_const<const T&> : mpl::true_ { };
+
+ template <class T>
+ specifier make_specifier()
+ {
+ modifiers mods;
+ mods.set_const(is_const<T>::value); // what is wrong with boost::is_const<T> ??
+ mods.set_reference(boost::is_reference<T>::value);
+ return specifier();//(traits<typename base_type<T>::Type>::type_number, mods);
+ };
 
 } // namespace type
 

Modified: sandbox/monotonic/boost/object_model/type/traits.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/type/traits.hpp (original)
+++ sandbox/monotonic/boost/object_model/type/traits.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -17,46 +17,46 @@
 
 namespace type
 {
- template <class T, size_t N, class S = T>
- struct traits_base
- {
- typedef S Storage;
- typedef Storage storage_type;
- typedef Storage *pointer_type;
- typedef Storage &reference_type;
- typedef Storage const &const_reference_type;
- };
+ template <class T, size_t N, class S = T>
+ struct traits_base
+ {
+ typedef S Storage;
+ typedef Storage storage_type;
+ typedef Storage *pointer_type;
+ typedef Storage &reference_type;
+ typedef Storage const &const_reference_type;
+ };
 
- struct any { };
- struct none { };
+ struct any { };
+ struct none { };
 }
 
 #ifdef BOOST_OBJECT_MODEL_MAIN
-# define BOOST_OBJECT_MODEL_DEFINE_NAME(T, NAME) \
- const char * traits<T>::name = NAME;
+# define BOOST_OBJECT_MODEL_DEFINE_NAME(T, NAME) \
+ const char * traits<T>::name = NAME;
 #else
-# define BOOST_OBJECT_MODEL_DEFINE_NAME(T, NAME)
+# define BOOST_OBJECT_MODEL_DEFINE_NAME(T, NAME)
 #endif
 
 #define BOOST_OBJECT_MODEL_TRAITS_NUM_STORE_NAME(T,N,S,NAME) \
- BOOST_OM_BEGIN \
- namespace type \
- { \
- template <> \
- struct traits<T> : traits_base<T,N,S> \
- { \
- BOOST_STATIC_CONSTANT(number::value_type, type_number = N); \
- static const char *name; \
- }; \
- BOOST_OBJECT_MODEL_DEFINE_NAME(T,NAME); \
- } \
- BOOST_OM_END
+ BOOST_OM_BEGIN \
+ namespace type \
+ { \
+ template <> \
+ struct traits<T> : traits_base<T,N,S> \
+ { \
+ BOOST_STATIC_CONSTANT(number::value_type, type_number = N); \
+ static const char *name; \
+ }; \
+ BOOST_OBJECT_MODEL_DEFINE_NAME(T,NAME); \
+ } \
+ BOOST_OM_END
 
 #define BOOST_OBJECT_MODEL_TRAITS_NUM_STORE(T,N,S) \
- BOOST_OBJECT_MODEL_TRAITS_NUM_STORE_NAME(T,N,S,BOOST_PP_STRINGIZE(T))
+ BOOST_OBJECT_MODEL_TRAITS_NUM_STORE_NAME(T,N,S,BOOST_PP_STRINGIZE(T))
 
 #define BOOST_OBJECT_MODEL_TRAITS_NUM(T,N) \
- BOOST_OBJECT_MODEL_TRAITS_NUM_STORE(T,N,T)
+ BOOST_OBJECT_MODEL_TRAITS_NUM_STORE(T,N,T)
 
 BOOST_OM_END
 

Modified: sandbox/monotonic/boost/utility/iter_range.hpp
==============================================================================
--- sandbox/monotonic/boost/utility/iter_range.hpp (original)
+++ sandbox/monotonic/boost/utility/iter_range.hpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -7,149 +7,149 @@
 
 namespace boost
 {
- namespace iter_range_detail
- {
- template <class Iter>
- struct iter_range : std::pair<Iter, Iter>
- {
- typedef std::pair<Iter, Iter> Parent;
- using Parent::first;
- using Parent::second;
-
- iter_range() { }
- iter_range(Iter const &A, Iter const &B)
- : Parent(A,B) { }
-
- size_t size() const
- {
- return std::distance(this->first, this->second);
- }
- bool empty() const
- {
- return first == second;
- }
- void advance(size_t N)
- {
- std::advance(first, N);
- }
- iter_range& operator++()
- {
- BOOST_ASSERT(*this);
- ++first;
- return *this;
- }
- iter_range operator++(int)
- {
- BOOST_ASSERT(*this);
- iter_range tmp(*this);
- ++*this;
- return tmp;
- }
- iter_range& operator--()
- {
- BOOST_ASSERT(*this);
- --first;
- return *this;
- }
- iter_range operator--(int)
- {
- BOOST_ASSERT(*this);
- iter_range tmp(*this);
- --*this;
- return tmp;
- }
- operator bool() const
- {
- return first != second;
- }
- };
- }
-
- template <class C>
- struct iter_range : iter_range_detail::iter_range<typename C::iterator>
- {
- typedef C Container;
- typedef typename Container::iterator iterator;
- typedef iter_range_detail::iter_range<iterator> Parent;
- typedef typename boost::iterator_value<iterator>::type Value;
- using Parent::first;
- using Parent::second;
-
- iter_range() { }
- iter_range(Container &cont)
- : Parent(cont.begin(), cont.end()) { }
- iter_range(iterator A)
- : Parent(A,A) { }
- iter_range(iterator A, iterator B)
- : Parent(A,B) { }
- iter_range& operator++()
- {
- Parent::operator++();
- return *this;
- }
- iter_range operator++(int)
- {
- iter_range tmp(*this);
- Parent::operator++(0);
- return tmp;
- }
- Value &operator*() const
- {
- return *first;
- }
- };
-
- template <class C>
- struct const_iter_range : iter_range_detail::iter_range<typename C::const_iterator>
- {
- typedef C Container;
- typedef typename Container::const_iterator const_iterator;
- typedef iter_range_detail::iter_range<const_iterator> Parent;
- typedef typename boost::iterator_value<const_iterator>::type Value;
- using Parent::first;
- using Parent::second;
-
- const_iter_range() { }
- template <class C2>
- const_iter_range(iter_range<C2> const &R)
- : Parent(R.first, R.second) { }
- const_iter_range(Container const &cont)
- : Parent(cont.begin(), cont.end()) { }
- const_iter_range(const_iterator A)
- : Parent(A,A) { }
- const_iter_range(const_iterator A, const_iterator B)
- : Parent(A,B) { }
- const_iter_range& operator++()
- {
- Parent::operator++();
- return *this;
- }
- const_iter_range operator++(int)
- {
- const_iter_range tmp(*this);
- Parent::operator++(0);
- return tmp;
- }
- const Value &operator*() const
- {
- return *first;
- }
- };
- template <class C>
- const_iter_range<C> make_const_range(C &X)
- {
- return const_iter_range<C>(X);
- }
- template <class C>
- const_iter_range<C> make_iter_range(C const &X)
- {
- return const_iter_range<C>(X);
- }
- template <class C>
- const_iter_range<C> make_iter_range(C &X)
- {
- return iter_range<C>(X);
- }
+ namespace iter_range_detail
+ {
+ template <class Iter>
+ struct iter_range : std::pair<Iter, Iter>
+ {
+ typedef std::pair<Iter, Iter> Parent;
+ using Parent::first;
+ using Parent::second;
+
+ iter_range() { }
+ iter_range(Iter const &A, Iter const &B)
+ : Parent(A,B) { }
+
+ size_t size() const
+ {
+ return std::distance(this->first, this->second);
+ }
+ bool empty() const
+ {
+ return first == second;
+ }
+ void advance(size_t N)
+ {
+ std::advance(first, N);
+ }
+ iter_range& operator++()
+ {
+ BOOST_ASSERT(*this);
+ ++first;
+ return *this;
+ }
+ iter_range operator++(int)
+ {
+ BOOST_ASSERT(*this);
+ iter_range tmp(*this);
+ ++*this;
+ return tmp;
+ }
+ iter_range& operator--()
+ {
+ BOOST_ASSERT(*this);
+ --first;
+ return *this;
+ }
+ iter_range operator--(int)
+ {
+ BOOST_ASSERT(*this);
+ iter_range tmp(*this);
+ --*this;
+ return tmp;
+ }
+ operator bool() const
+ {
+ return first != second;
+ }
+ };
+ }
+
+ template <class C>
+ struct iter_range : iter_range_detail::iter_range<typename C::iterator>
+ {
+ typedef C Container;
+ typedef typename Container::iterator iterator;
+ typedef iter_range_detail::iter_range<iterator> Parent;
+ typedef typename boost::iterator_value<iterator>::type Value;
+ using Parent::first;
+ using Parent::second;
+
+ iter_range() { }
+ iter_range(Container &cont)
+ : Parent(cont.begin(), cont.end()) { }
+ iter_range(iterator A)
+ : Parent(A,A) { }
+ iter_range(iterator A, iterator B)
+ : Parent(A,B) { }
+ iter_range& operator++()
+ {
+ Parent::operator++();
+ return *this;
+ }
+ iter_range operator++(int)
+ {
+ iter_range tmp(*this);
+ Parent::operator++(0);
+ return tmp;
+ }
+ Value &operator*() const
+ {
+ return *first;
+ }
+ };
+
+ template <class C>
+ struct const_iter_range : iter_range_detail::iter_range<typename C::const_iterator>
+ {
+ typedef C Container;
+ typedef typename Container::const_iterator const_iterator;
+ typedef iter_range_detail::iter_range<const_iterator> Parent;
+ typedef typename boost::iterator_value<const_iterator>::type Value;
+ using Parent::first;
+ using Parent::second;
+
+ const_iter_range() { }
+ template <class C2>
+ const_iter_range(iter_range<C2> const &R)
+ : Parent(R.first, R.second) { }
+ const_iter_range(Container const &cont)
+ : Parent(cont.begin(), cont.end()) { }
+ const_iter_range(const_iterator A)
+ : Parent(A,A) { }
+ const_iter_range(const_iterator A, const_iterator B)
+ : Parent(A,B) { }
+ const_iter_range& operator++()
+ {
+ Parent::operator++();
+ return *this;
+ }
+ const_iter_range operator++(int)
+ {
+ const_iter_range tmp(*this);
+ Parent::operator++(0);
+ return tmp;
+ }
+ const Value &operator*() const
+ {
+ return *first;
+ }
+ };
+ template <class C>
+ const_iter_range<C> make_const_range(C &X)
+ {
+ return const_iter_range<C>(X);
+ }
+ template <class C>
+ const_iter_range<C> make_iter_range(C const &X)
+ {
+ return const_iter_range<C>(X);
+ }
+ template <class C>
+ const_iter_range<C> make_iter_range(C &X)
+ {
+ return iter_range<C>(X);
+ }
 }
 
 //EOF

Modified: sandbox/monotonic/libs/monotonic/doc/html/index.html
==============================================================================
--- sandbox/monotonic/libs/monotonic/doc/html/index.html (original)
+++ sandbox/monotonic/libs/monotonic/doc/html/index.html 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -28,7 +28,7 @@
 </h3></div></div></div>
 <div><p class="copyright">Copyright © 2009 Christian Schladetsch</p></div>
 <div><div class="legalnotice" title="Legal Notice">
-<a name="id667547"></a><p>
+<a name="id670824"></a><p>
         Distributed under the Boost Software License, Version 1.0. (See accompanying
         file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
       </p>
@@ -55,7 +55,7 @@
 </div>
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"><p><small>Last revised: July 06, 2009 at 22:47:08 GMT</small></p></td>
+<td align="left"><p><small>Last revised: July 07, 2009 at 09:33:35 GMT</small></p></td>
 <td align="right"><div class="copyright-footer"></div></td>
 </tr></table>
 <hr>

Modified: sandbox/monotonic/libs/monotonic/doc/html/monotonic_storage/change_log.html
==============================================================================
--- sandbox/monotonic/libs/monotonic/doc/html/monotonic_storage/change_log.html (original)
+++ sandbox/monotonic/libs/monotonic/doc/html/monotonic_storage/change_log.html 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -27,14 +27,14 @@
 <a name="monotonic_storage.change_log"></a><a class="link" href="change_log.html" title="Change Log"> Change Log</a>
 </h2></div></div></div>
 <a name="monotonic_storage.change_log.version_0_4"></a><h4>
-<a name="id667653"></a>
+<a name="id670966"></a>
       <a class="link" href="change_log.html#monotonic_storage.change_log.version_0_4">Version 0.4</a>
     </h4>
 <div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
         Added reclaimable storage
       </li></ul></div>
 <a name="monotonic_storage.change_log.version_0_3"></a><h4>
-<a name="id667673"></a>
+<a name="id670986"></a>
       <a class="link" href="change_log.html#monotonic_storage.change_log.version_0_3">Version 0.3</a>
     </h4>
 <div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">

Modified: sandbox/monotonic/libs/monotonic/doc/html/monotonic_storage/containers.html
==============================================================================
--- sandbox/monotonic/libs/monotonic/doc/html/monotonic_storage/containers.html (original)
+++ sandbox/monotonic/libs/monotonic/doc/html/monotonic_storage/containers.html 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -30,7 +30,7 @@
 <p>
       Along with an allocator, storage and stack system, the Monotonic library provides
       a set of containers that use stateful monotonic allocators
- <sup>[<a name="id673522" href="#ftn.id673522" class="footnote">1</a>]</sup>
+ <sup>[<a name="id677241" href="#ftn.id677241" class="footnote">5</a>]</sup>
       .
     </p>
 <p>
@@ -84,7 +84,7 @@
 </table></div>
 <div class="footnotes">
 <br><hr width="100" align="left">
-<div class="footnote"><p><sup>[<a name="ftn.id673522" href="#id673522" class="para">1</a>] </sup>
+<div class="footnote"><p><sup>[<a name="ftn.id677241" href="#id677241" class="para">5</a>] </sup>
           these are based on boost::interprocess::containers
         </p></div>
 </div>

Modified: sandbox/monotonic/libs/monotonic/doc/html/monotonic_storage/intro.html
==============================================================================
--- sandbox/monotonic/libs/monotonic/doc/html/monotonic_storage/intro.html (original)
+++ sandbox/monotonic/libs/monotonic/doc/html/monotonic_storage/intro.html 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -31,10 +31,12 @@
       allocation and container types for use in high-performance and real-time applications.
     </p>
 <p>
- The library provides a means for allocation to come from the stack, or the
- heap, or a combination of both the stack and the heap. Allocation is fast,
- because de-allocation does nothing. As such, the amount of storage used by
- a monotonic allocator can only ever increase - hence the name of the library.
+ The library provides a means for allocation to come from the BSS, stack, or
+ the heap, or transparently from a combination of the BSS, stack and heap. Allocation
+ is fast, because de-allocation does nothing
+ <sup>[<a name="id670865" href="#ftn.id670865" class="footnote">1</a>]</sup>
+ . As such, the amount of storage used by a monotonic allocator can only ever
+ increase - hence the name of the library. A LIFO allocation model is also provided.
     </p>
 <p>
       Allocation can be <span class="emphasis"><em>regionalised</em></span> by application of user-supplied
@@ -44,10 +46,16 @@
     </p>
 <p>
       <span class="bold"><strong>Boost.Monotonic</strong></span> is generally used where performace
- is a key concern. By making deallocation a no-op, allocation of memory resources
- is extremely fast. In general, the programmer is required to release storage
- used at an appropriate time, however local scoping systems are provided by
- the library for the most common use cases.
+ is a key concern, but there are many use-cases where use of this library provides
+ new functionality
+ <sup>[<a name="id670909" href="#ftn.id670909" class="footnote">2</a>]</sup>
+ .
+ </p>
+<p>
+ By making deallocation a no-op, allocation of memory resources is extremely
+ fast. In general, the programmer is required to release storage used at an
+ appropriate time, however local scoping systems are provided by the library
+ for the most common use cases.
     </p>
 <p>
       Features include:
@@ -73,6 +81,15 @@
         stack and the heap
       </li>
 </ul></div>
+<div class="footnotes">
+<br><hr width="100" align="left">
+<div class="footnote"><p><sup>[<a name="ftn.id670865" href="#id670865" class="para">1</a>] </sup>
+ except for <code class="computeroutput"><span class="identifier">monotonic</span><span class="special">::</span><span class="identifier">stack</span><span class="special">&lt;&gt;</span></code>
+ </p></div>
+<div class="footnote"><p><sup>[<a name="ftn.id670909" href="#id670909" class="para">2</a>] </sup>
+ such as in self- or mutually-recursive algorithms
+ </p></div>
+</div>
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>

Modified: sandbox/monotonic/libs/monotonic/doc/html/monotonic_storage/tutorial/stack.html
==============================================================================
--- sandbox/monotonic/libs/monotonic/doc/html/monotonic_storage/tutorial/stack.html (original)
+++ sandbox/monotonic/libs/monotonic/doc/html/monotonic_storage/tutorial/stack.html 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -28,7 +28,11 @@
 </h3></div></div></div>
 <p>
         While monotonic allocators use monotonic storage, we can also use this storage
- directly and wherever we want efficient resource management.
+ directly and wherever we want efficient resource management. Using a <code class="computeroutput"><span class="identifier">monotonic</span><span class="special">::</span><span class="identifier">stack</span><span class="special">&lt;&gt;</span></code>
+ gives you a first-class C++ stack which you can use at will, pass as an argument
+ or return as a result
+ <sup>[<a name="id675842" href="#ftn.id675842" class="footnote">3</a>]</sup>
+ .
       </p>
 <p>
         The general usage pattern is:
@@ -43,8 +47,7 @@
     <span class="special">....</span>
     <span class="identifier">Tn</span> <span class="special">&amp;</span><span class="identifier">tn</span> <span class="special">=</span> <span class="identifier">stack</span><span class="special">.</span><span class="identifier">push</span><span class="special">&lt;</span><span class="identifier">Tn</span><span class="special">&gt;(..</span><span class="identifier">args</span><span class="special">..);</span>
     
- <span class="identifier">boost</span><span class="special">::</span><span class="identifier">array</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">Size</span><span class="special">&gt;</span> <span class="special">&amp;</span><span class="identifier">array</span> <span class="special">=</span> <span class="identifier">stack</span><span class="special">.</span><span class="identifier">push_array</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">Size</span><span class="special">&gt;();</span>
-
+ <span class="identifier">stack</span><span class="special">.</span><span class="identifier">pop</span><span class="special">();</span>
     <span class="identifier">stack</span><span class="special">.</span><span class="identifier">pop</span><span class="special">();</span>
     <span class="special">...</span>
 <span class="special">}</span>
@@ -52,17 +55,32 @@
 <p>
       </p>
 <p>
- The default inline size of a <code class="computeroutput"><span class="identifier">stack</span><span class="special">&lt;&gt;</span></code> object is defined as <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">monotonic</span><span class="special">::</span><span class="identifier">DefaltSizes</span><span class="special">::</span><span class="identifier">InlineSize</span></code>.
+ Objects are created in-place using <span class="emphasis"><em>emplace</em></span> semantics.
+ You just provide the type and construction arguments - your object will be
+ either on the stack or the heap and you needn't worry either way. Objects
+ are <span class="emphasis"><em>not</em></span> copied, which means you can safely use types
+ that do not have default constructors or assignment overloads with <code class="computeroutput"><span class="identifier">stack</span><span class="special">&lt;&gt;</span></code>.
+ </p>
+<p>
+ All objects pushed onto the <code class="computeroutput"><span class="identifier">stack</span><span class="special">&lt;&gt;</span></code> are destroyed when the stack leaves
+ scope - there is no need to pop them all explicitly. New objects can be added
+ between <code class="computeroutput"><span class="identifier">push</span></code> and <code class="computeroutput"><span class="identifier">pop</span></code>.
+ </p>
+<p>
+ You can set the amount of C++ machine stack to use by saying <code class="computeroutput"><span class="identifier">stack</span><span class="special">&lt;</span><span class="identifier">num_bytes</span><span class="special">&gt;</span></code>.The
+ default inline size of a <code class="computeroutput"><span class="identifier">stack</span><span class="special">&lt;&gt;</span></code> object is defined as <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">monotonic</span><span class="special">::</span><span class="identifier">DefaltSizes</span><span class="special">::</span><span class="identifier">InlineSize</span></code>.
       </p>
 <p>
         We can use a <code class="computeroutput"><span class="identifier">stack</span><span class="special">&lt;&gt;</span></code>
         as a platform-independant <code class="computeroutput"><span class="identifier">alloca</span><span class="special">(</span><span class="identifier">size</span><span class="special">)</span></code>
- by pushing an array of bytes, as shown above.
+ by pushing an array of bytes, by using <code class="computeroutput"><span class="identifier">stack</span><span class="special">.</span><span class="identifier">push</span><span class="special">&lt;</span><span class="keyword">char</span> <span class="special">[</span><span class="identifier">N</span><span class="special">]&gt;</span></code> or <code class="computeroutput"><span class="identifier">stack</span><span class="special">.</span><span class="identifier">push</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">array</span><span class="special">&lt;</span><span class="keyword">char</span><span class="special">,</span> <span class="identifier">N</span><span class="special">&gt;</span> <span class="special">&gt;</span></code>
+ or more generally <code class="computeroutput"><span class="identifier">stack</span><span class="special">.</span><span class="identifier">push_array</span><span class="special">&lt;</span><span class="identifier">Ty</span><span class="special">,</span> <span class="identifier">N</span><span class="special">&gt;</span></code>.
       </p>
 <p>
         When we call <code class="computeroutput"><span class="identifier">stack</span><span class="special">.</span><span class="identifier">pop</span><span class="special">()</span></code>,
         the last value added to the stack is destroyed and the stack pointer is set
- to the start of the previous object on the stack. Calling <code class="computeroutput"><span class="identifier">pop</span></code>
+ to the end of the previous object on the stack. Objects are added using correct
+ machine alignment. Calling <code class="computeroutput"><span class="identifier">pop</span></code>
         on an empty stack throws an <code class="computeroutput"><span class="identifier">empty_stack</span></code>
         exception.
       </p>
@@ -90,8 +108,14 @@
     
     <span class="identifier">array</span><span class="special">&lt;</span><span class="keyword">char</span><span class="special">,</span> <span class="number">1000</span><span class="special">&gt;</span> <span class="special">&amp;</span><span class="identifier">bytes</span> <span class="special">=</span> <span class="identifier">stack</span><span class="special">.</span><span class="identifier">push_array</span><span class="special">&lt;</span><span class="keyword">char</span><span class="special">,</span> <span class="number">1000</span><span class="special">&gt;();</span>
     
- <span class="identifier">size_t</span> <span class="identifier">size</span> <span class="special">=</span> <span class="identifier">stack</span><span class="special">.</span><span class="identifier">size</span><span class="special">();</span>
- <span class="identifier">Stack</span><span class="special">::</span><span class="identifier">const_iterator</span> <span class="identifier">elem</span> <span class="special">=</span> <span class="identifier">stack</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">end</span> <span class="special">=</span> <span class="identifier">stack</span><span class="special">.</span><span class="identifier">end</span><span class="special">();</span>
+ <span class="comment">// number of elements on the stack
+</span> <span class="identifier">size_t</span> <span class="identifier">size</span> <span class="special">=</span> <span class="identifier">stack</span><span class="special">.</span><span class="identifier">size</span><span class="special">();</span>
+
+ <span class="comment">// number of bytes used
+</span> <span class="identifier">size_t</span> <span class="identifier">used_bytes</span> <span class="special">=</span> <span class="identifier">stack</span><span class="special">.</span><span class="identifier">bytes_used</span><span class="special">();</span>
+
+ <span class="comment">// iterate over heterogenous elements
+</span> <span class="identifier">Stack</span><span class="special">::</span><span class="identifier">const_iterator</span> <span class="identifier">elem</span> <span class="special">=</span> <span class="identifier">stack</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">end</span> <span class="special">=</span> <span class="identifier">stack</span><span class="special">.</span><span class="identifier">end</span><span class="special">();</span>
     <span class="keyword">for</span> <span class="special">(;</span> <span class="identifier">elem</span> <span class="special">!=</span> <span class="identifier">end</span><span class="special">;</span> <span class="special">++</span><span class="identifier">elem</span><span class="special">)</span>
     <span class="special">{</span>
         <span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">elem</span><span class="special">-&gt;</span><span class="identifier">get_type</span><span class="special">().</span><span class="identifier">name</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">endl</span><span class="special">;</span>
@@ -105,9 +129,6 @@
     <span class="comment">// stacks are first-class objects and can be copied, passed
 </span> <span class="comment">// as arguments and returned as results
 </span> <span class="identifier">Stack</span> <span class="identifier">copy</span> <span class="special">=</span> <span class="identifier">stack</span><span class="special">;</span>
-
- <span class="comment">// unecessary in this case; will be cleared when stack leaves scope
-</span> <span class="identifier">stack</span><span class="special">.</span><span class="identifier">clear</span><span class="special">();</span>
 <span class="special">}</span>
 </pre>
 <p>
@@ -118,17 +139,66 @@
         and functions and even across process boundaries, independantly of the underlying
         machine-based stack. They can be copied and compared and iterated over.
       </p>
+<div class="warning" title="Warning"><table border="0" summary="Warning">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../../doc/html/images/warning.png"></td>
+<th align="left">Warning</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ Copying <code class="computeroutput"><span class="identifier">stack</span><span class="special">&lt;&gt;</span></code>
+ objects performs a slicing copy. To safely copy general stacks, use <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">cloneable</span><span class="special">::</span><span class="identifier">stack</span><span class="special">&lt;&gt;</span></code>
+ <sup>[<a name="id677014" href="#ftn.id677014" class="footnote">4</a>]</sup>
+ instead
+ </p></td></tr>
+</table></div>
+<p>
+ Unlike the C++ stack, storage for a <code class="computeroutput"><span class="identifier">stack</span><span class="special">&lt;&gt;</span></code> will use the heap when its local
+ inline stack-based buffer is exhuasted. This makes it ideal for local buffers
+ that will generally be small enough to fit onto the stack, but with the fallback
+ safety of transparently using the heap to service later requests for the
+ cases where that inline buffer is not large enough. This is especially useful
+ in recursive functions, which can be readily re-written to use a <code class="computeroutput"><span class="identifier">monotonic</span><span class="special">::</span><span class="identifier">stack</span><span class="special">&lt;&gt;</span></code>
+ and thus be divorced from the limitations of the C++ stack.
+ </p>
+<div class="note" title="Note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/html/images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ When a <code class="computeroutput"><span class="identifier">stack</span><span class="special">&lt;&gt;</span></code>
+ goes out of scope, all objects in that stack are destroyed
+ </p></td></tr>
+</table></div>
 <p>
- Also unlike the stack, storage will use the heap when its local inline stack-based
- buffer is exhuasted. This makes it ideal for using things like local buffers
- and containers that generally will be small enough to fit onto the stack,
- but with the fallback safety of transparently using the heap to service later
- requests for the cases where that inline buffer is not large enough.
+ You can use <code class="computeroutput"><span class="identifier">monotonic</span><span class="special">::</span><span class="identifier">enter</span></code> to localise usage of a stack:
       </p>
 <p>
- When a stack goes out of scope, all objects in that stack are automatically
- destroyed.
+
+</p>
+<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Stack</span><span class="special">&gt;</span>
+<span class="keyword">void</span> <span class="identifier">UseStack</span><span class="special">(</span><span class="identifier">Stack</span> <span class="special">&amp;</span><span class="identifier">stack</span><span class="special">)</span>
+<span class="special">{</span>
+ <span class="identifier">monotonic</span><span class="special">::</span><span class="identifier">enter</span> <span class="identifier">local</span><span class="special">(</span><span class="identifier">stack</span><span class="special">);</span>
+<span class="special">}</span>
+</pre>
+<p>
       </p>
+<p>
+ This ensures that the stack leaves in the same state that it entered, by
+ <code class="computeroutput"><span class="identifier">pop</span></code>ping until the stack is
+ balanced. If the stack is smaller when <code class="computeroutput"><span class="identifier">local</span></code>
+ leaves scope than when it entered scope, it will throw <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">monotonic</span><span class="special">::</span><span class="identifier">uneven_stack</span></code>.
+ </p>
+<div class="footnotes">
+<br><hr width="100" align="left">
+<div class="footnote"><p><sup>[<a name="ftn.id675842" href="#id675842" class="para">3</a>] </sup>
+ To avoid slicing copies, use Boost.Cloneable.Stack
+ </p></div>
+<div class="footnote"><p><sup>[<a name="ftn.id677014" href="#id677014" class="para">4</a>] </sup>
+ TODO
+ </p></div>
+</div>
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>

Modified: sandbox/monotonic/libs/monotonic/doc/monotonic.qbk
==============================================================================
--- sandbox/monotonic/libs/monotonic/doc/monotonic.qbk (original)
+++ sandbox/monotonic/libs/monotonic/doc/monotonic.qbk 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -76,16 +76,18 @@
 The [*Boost.Monotonic] library provides storage, allocation and container types for use
 in high-performance and real-time applications.
 
-The library provides a means for allocation to come from the stack, or the heap, or a combination of
- both the stack and the heap. Allocation is fast, because de-allocation does nothing.
+The library provides a means for allocation to come from the BSS, stack, or the heap, or transparently from a
+combination of the BSS, stack and heap. Allocation is fast, because de-allocation does nothing[footnote except for `monotonic::stack<>`] .
  As such, the amount of storage used by a monotonic allocator can only ever increase
- - hence the name of the library.
+ - hence the name of the library. A LIFO allocation model is also provided.
 
 Allocation can be ['regionalised] by application of user-supplied 'tag types' to specify a
 logical storage region. A second tag may be used to specify the
 ['access type] for the region - which can be either global, guarded by a mutex, or using thread-local storage.
 
-[*Boost.Monotonic] is generally used where performace is a key concern.
+[*Boost.Monotonic] is generally used where performace is a key concern, but there are many use-cases where
+use of this library provides new functionality[footnote such as in self- or mutually-recursive algorithms].
+
 By making deallocation a no-op, allocation of memory resources is extremely fast.
 In general, the programmer is required to release storage used at an appropriate time,
 however local scoping systems are provided by the library for the most common use cases.
@@ -269,7 +271,9 @@
 [section Stack]
 
 While monotonic allocators use monotonic storage, we can also use this storage
-directly and wherever we want efficient resource management.
+directly and wherever we want efficient resource management. Using a `monotonic::stack<>`
+gives you a first-class C++ stack which you can use at will, pass as an argument or return
+as a result[footnote To avoid slicing copies, use Boost.Cloneable.Stack].
 
 The general usage pattern is:
 
@@ -281,19 +285,27 @@
     ....
     Tn &tn = stack.push<Tn>(..args..);
     
- boost::array<T, Size> &array = stack.push_array<T, Size>();
-
+ stack.pop();
     stack.pop();
     ...
 }
 ``
 
-The default inline size of a `stack<>` object is defined as `boost::monotonic::DefaltSizes::InlineSize`.
+Objects are created in-place using /emplace/ semantics. You just provide the type and construction arguments - your object
+will be either on the stack or the heap and you needn't worry either way. Objects are /not/ copied, which means you
+can safely use types that do not have default constructors or assignment overloads with `stack<>`.
+
+All objects pushed onto the `stack<>` are destroyed when the stack leaves scope - there is no need to pop them all explicitly.
+New objects can be added between `push` and `pop`.
+
+You can set the amount of C++ machine stack to use by saying `stack<num_bytes>`.The default inline size of a `stack<>`
+object is defined as `boost::monotonic::DefaltSizes::InlineSize`.
 
-We can use a `stack<>` as a platform-independant `alloca(size)` by pushing an array of bytes, as shown above.
+We can use a `stack<>` as a platform-independant `alloca(size)` by pushing an array of bytes, by using `stack.push<char [N]>` or
+`stack.push<boost::array<char, N> >` or more generally `stack.push_array<Ty, N>`.
 
 When we call `stack.pop()`, the last value added to the stack is destroyed and the stack pointer is set to
-the start of the previous object on the stack. Calling `pop` on an empty stack throws an `empty_stack` exception.
+the end of the previous object on the stack. Objects are added using correct machine alignment. Calling `pop` on an empty stack throws an `empty_stack` exception.
 
 [note It is best practise to open a new statement block before using a `stack<>` object. This ensures that the objects
 on the `stack<>` still have storage when when they are automatically deleted]
@@ -308,7 +320,13 @@
     
     array<char, 1000> &bytes = stack.push_array<char, 1000>();
     
+ // number of elements on the stack
     size_t size = stack.size();
+
+ // number of bytes used
+ size_t used_bytes = stack.bytes_used();
+
+ // iterate over heterogenous elements
     Stack::const_iterator elem = stack.begin(), end = stack.end();
     for (; elem != end; ++elem)
     {
@@ -323,9 +341,6 @@
     // stacks are first-class objects and can be copied, passed
     // as arguments and returned as results
     Stack copy = stack;
-
- // unecessary in this case; will be cleared when stack leaves scope
- stack.clear();
 }
 ``
 
@@ -333,15 +348,33 @@
 between objects and functions and even across process boundaries, independantly of the
 underlying machine-based stack. They can be copied and compared and iterated over.
 
-Also unlike the stack, storage will use the heap when its local inline stack-based buffer is exhuasted.
-This makes it ideal for using things like local buffers and containers that generally will be small
+[warning Copying `stack<>` objects performs a slicing copy.
+To safely copy general stacks, use `boost::cloneable::stack<>`[footnote TODO] instead]
+
+Unlike the C++ stack, storage for a `stack<>` will use the heap when its local inline stack-based buffer is exhuasted.
+This makes it ideal for local buffers that will generally be small
 enough to fit onto the stack, but with the fallback safety of transparently using the heap to
-service later requests for the cases where that inline buffer is not large enough.
+service later requests for the cases where that inline buffer is not large enough. This is
+especially useful in recursive functions, which can be readily re-written to use a `monotonic::stack<>` and
+thus be divorced from the limitations of the C++ stack.
 
-When a stack goes out of scope, all objects in that stack are automatically destroyed.
+[note When a `stack<>` goes out of scope, all objects in that stack are destroyed]
 
-[endsect]
+You can use `monotonic::enter` to localise
+usage of a stack:
+
+``
+template <class Stack>
+void UseStack(Stack &stack)
+{
+ monotonic::enter local(stack);
+}
+``
 
+This ensures that the stack leaves in the same state that it entered, by `pop`ping until the stack is balanced. If the stack is smaller
+when `local` leaves scope than when it entered scope, it will throw `boost::monotonic::uneven_stack`.
+
+[endsect]
 
 [endsect]
 

Modified: sandbox/monotonic/libs/monotonic/test/AllocatorTypes.h
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/AllocatorTypes.h (original)
+++ sandbox/monotonic/libs/monotonic/test/AllocatorTypes.h 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -20,28 +20,28 @@
 
 struct Type
 {
- enum Value
- {
- None = 0,
- Standard = 1,
- FastPool = 2,
- Pool = 4,
- Monotonic = 8,
- TBB = 16,
- Google = 32,
- All = 0xffffffff,
- };
- unsigned flags;
- Type(unsigned bits = All) : flags(bits) { }
- bool Includes(unsigned bit) const { return (flags & bit) != 0; }
- void Exclude(unsigned bit) { flags &= ~bit; }
- void Include(unsigned bit) { flags |= bit; }
- std::string ToString() const;
+ enum Value
+ {
+ None = 0,
+ Standard = 1,
+ FastPool = 2,
+ Pool = 4,
+ Monotonic = 8,
+ TBB = 16,
+ Google = 32,
+ All = 0xffffffff,
+ };
+ unsigned flags;
+ Type(unsigned bits = All) : flags(bits) { }
+ bool Includes(unsigned bit) const { return (flags & bit) != 0; }
+ void Exclude(unsigned bit) { flags &= ~bit; }
+ void Include(unsigned bit) { flags |= bit; }
+ std::string ToString() const;
 };
 
 struct Location
 {
- enum { Heap, Stack };
+ enum { Heap, Stack };
 };
 
 template <size_t Num, class Ty>
@@ -52,13 +52,13 @@
 
 template <class Ty>
 struct Allocator<Type::FastPool, Ty> : boost::fast_pool_allocator<Ty
- , boost::default_user_allocator_new_delete
- , boost::details::pool::null_mutex> { };
+ , boost::default_user_allocator_new_delete
+ , boost::details::pool::null_mutex> { };
 
 template <class Ty>
 struct Allocator<Type::Pool, Ty> : boost::pool_allocator<Ty
- , boost::default_user_allocator_new_delete
- , boost::details::pool::null_mutex> { };
+ , boost::default_user_allocator_new_delete
+ , boost::details::pool::null_mutex> { };
 
 template <class Ty>
 struct Allocator<Type::Monotonic, Ty> : boost::monotonic::allocator<Ty> { };
@@ -69,22 +69,22 @@
 template <class Alloc, class T>
 struct Rebind
 {
- typedef typename Alloc::template rebind<T>::other type;
+ typedef typename Alloc::template rebind<T>::other type;
 };
 
 struct Unaligned
 {
- char c[5];
- Unaligned() { }
- Unaligned(char C)
- {
- c[2] = C;
- }
+ char c[5];
+ Unaligned() { }
+ Unaligned(char C)
+ {
+ c[2] = C;
+ }
 };
 
 inline bool operator<(Unaligned const &A, Unaligned const &B)
 {
- return A.c[2] < B.c[2];
+ return A.c[2] < B.c[2];
 }
 
 //EOF

Modified: sandbox/monotonic/libs/monotonic/test/PoolResult.h
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/PoolResult.h (original)
+++ sandbox/monotonic/libs/monotonic/test/PoolResult.h 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -12,110 +12,110 @@
 
 struct PoolResult
 {
- //boost::array<double, Type:: elapsed[;
- double pool_elapsed;
- double fast_pool_elapsed;
- double mono_elapsed;
- double local_mono_elapsed;
- double std_elapsed;
- double tbb_elapsed;
- PoolResult(double D = 0)
- {
- tbb_elapsed = pool_elapsed = fast_pool_elapsed = mono_elapsed = local_mono_elapsed = std_elapsed = D;
- }
-
- PoolResult& operator+=(PoolResult const &A)
- {
- pool_elapsed += A.pool_elapsed;
- fast_pool_elapsed += A.fast_pool_elapsed;
- mono_elapsed += A.mono_elapsed;
- local_mono_elapsed += A.local_mono_elapsed;
- std_elapsed += A.std_elapsed;
- tbb_elapsed += A.tbb_elapsed;
- return *this;
- }
- PoolResult& operator-=(PoolResult const &A)
- {
- pool_elapsed -= A.pool_elapsed;
- fast_pool_elapsed -= A.fast_pool_elapsed;
- mono_elapsed -= A.mono_elapsed;
- local_mono_elapsed -= A.local_mono_elapsed;
- std_elapsed -= A.std_elapsed;
- tbb_elapsed -= A.tbb_elapsed;
- return *this;
- }
- PoolResult& operator*=(PoolResult const &A)
- {
- pool_elapsed *= A.pool_elapsed;
- fast_pool_elapsed *= A.fast_pool_elapsed;
- mono_elapsed *= A.mono_elapsed;
- local_mono_elapsed *= A.local_mono_elapsed;
- std_elapsed *= A.std_elapsed;
- tbb_elapsed *= A.tbb_elapsed;
- return *this;
- }
- PoolResult& operator*=(double A)
- {
- pool_elapsed *= A;
- fast_pool_elapsed *= A;
- mono_elapsed *= A;
- local_mono_elapsed *= A;
- std_elapsed *= A;
- tbb_elapsed *= A;
- return *this;
- }
-
- void update_min(PoolResult const &other)
- {
- // reject very small mins as we sometimes have 0-element tests
- if (other.fast_pool_elapsed > 0.01)
- fast_pool_elapsed = std::min(fast_pool_elapsed, other.fast_pool_elapsed);
- if (other.pool_elapsed > 0.01)
- pool_elapsed = std::min(pool_elapsed, other.pool_elapsed);
- if (other.tbb_elapsed > 0.01)
- tbb_elapsed = std::min(tbb_elapsed, other.tbb_elapsed);
- if (other.std_elapsed > 0.01)
- std_elapsed = std::min(std_elapsed, other.std_elapsed);
- }
- void update_max(PoolResult const &other)
- {
- fast_pool_elapsed = std::max(fast_pool_elapsed, other.fast_pool_elapsed);
- pool_elapsed = std::max(pool_elapsed, other.pool_elapsed);
- tbb_elapsed = std::max(tbb_elapsed, other.tbb_elapsed);
- std_elapsed = std::max(std_elapsed, other.std_elapsed);
- }
+ //boost::array<double, Type:: elapsed[;
+ double pool_elapsed;
+ double fast_pool_elapsed;
+ double mono_elapsed;
+ double local_mono_elapsed;
+ double std_elapsed;
+ double tbb_elapsed;
+ PoolResult(double D = 0)
+ {
+ tbb_elapsed = pool_elapsed = fast_pool_elapsed = mono_elapsed = local_mono_elapsed = std_elapsed = D;
+ }
+
+ PoolResult& operator+=(PoolResult const &A)
+ {
+ pool_elapsed += A.pool_elapsed;
+ fast_pool_elapsed += A.fast_pool_elapsed;
+ mono_elapsed += A.mono_elapsed;
+ local_mono_elapsed += A.local_mono_elapsed;
+ std_elapsed += A.std_elapsed;
+ tbb_elapsed += A.tbb_elapsed;
+ return *this;
+ }
+ PoolResult& operator-=(PoolResult const &A)
+ {
+ pool_elapsed -= A.pool_elapsed;
+ fast_pool_elapsed -= A.fast_pool_elapsed;
+ mono_elapsed -= A.mono_elapsed;
+ local_mono_elapsed -= A.local_mono_elapsed;
+ std_elapsed -= A.std_elapsed;
+ tbb_elapsed -= A.tbb_elapsed;
+ return *this;
+ }
+ PoolResult& operator*=(PoolResult const &A)
+ {
+ pool_elapsed *= A.pool_elapsed;
+ fast_pool_elapsed *= A.fast_pool_elapsed;
+ mono_elapsed *= A.mono_elapsed;
+ local_mono_elapsed *= A.local_mono_elapsed;
+ std_elapsed *= A.std_elapsed;
+ tbb_elapsed *= A.tbb_elapsed;
+ return *this;
+ }
+ PoolResult& operator*=(double A)
+ {
+ pool_elapsed *= A;
+ fast_pool_elapsed *= A;
+ mono_elapsed *= A;
+ local_mono_elapsed *= A;
+ std_elapsed *= A;
+ tbb_elapsed *= A;
+ return *this;
+ }
+
+ void update_min(PoolResult const &other)
+ {
+ // reject very small mins as we sometimes have 0-element tests
+ if (other.fast_pool_elapsed > 0.01)
+ fast_pool_elapsed = std::min(fast_pool_elapsed, other.fast_pool_elapsed);
+ if (other.pool_elapsed > 0.01)
+ pool_elapsed = std::min(pool_elapsed, other.pool_elapsed);
+ if (other.tbb_elapsed > 0.01)
+ tbb_elapsed = std::min(tbb_elapsed, other.tbb_elapsed);
+ if (other.std_elapsed > 0.01)
+ std_elapsed = std::min(std_elapsed, other.std_elapsed);
+ }
+ void update_max(PoolResult const &other)
+ {
+ fast_pool_elapsed = std::max(fast_pool_elapsed, other.fast_pool_elapsed);
+ pool_elapsed = std::max(pool_elapsed, other.pool_elapsed);
+ tbb_elapsed = std::max(tbb_elapsed, other.tbb_elapsed);
+ std_elapsed = std::max(std_elapsed, other.std_elapsed);
+ }
 };
 
 inline PoolResult sqrt(PoolResult const &A)
 {
- PoolResult R(A);
- R.fast_pool_elapsed = sqrt(R.fast_pool_elapsed);
- R.mono_elapsed = sqrt(R.mono_elapsed);
- R.local_mono_elapsed = sqrt(R.local_mono_elapsed);
- R.std_elapsed = sqrt(R.std_elapsed);
- R.tbb_elapsed = sqrt(R.tbb_elapsed);
- return R;
+ PoolResult R(A);
+ R.fast_pool_elapsed = sqrt(R.fast_pool_elapsed);
+ R.mono_elapsed = sqrt(R.mono_elapsed);
+ R.local_mono_elapsed = sqrt(R.local_mono_elapsed);
+ R.std_elapsed = sqrt(R.std_elapsed);
+ R.tbb_elapsed = sqrt(R.tbb_elapsed);
+ return R;
 }
 
 inline PoolResult operator*(PoolResult const &A, PoolResult const &B)
 {
- PoolResult R(A);
- R *= B;
- return R;
+ PoolResult R(A);
+ R *= B;
+ return R;
 }
 
 inline PoolResult operator+(PoolResult const &A, PoolResult const &B)
 {
- PoolResult R(A);
- R += B;
- return R;
+ PoolResult R(A);
+ R += B;
+ return R;
 }
 
 inline PoolResult operator-(PoolResult const &A, PoolResult const &B)
 {
- PoolResult R(A);
- R -= B;
- return R;
+ PoolResult R(A);
+ R -= B;
+ return R;
 }
 
 typedef std::map<size_t /*count*/, PoolResult> PoolResults;

Modified: sandbox/monotonic/libs/monotonic/test/Tests.h
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/Tests.h (original)
+++ sandbox/monotonic/libs/monotonic/test/Tests.h 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -14,202 +14,202 @@
 
 struct test_vector_create
 {
- template <class Alloc>
- int test(Alloc alloc, size_t length) const
- {
- std::vector<int, typename Rebind<Alloc, int>::type> vector(length*rand()/RAND_MAX);
- return vector.size();
- }
+ template <class Alloc>
+ int test(Alloc alloc, size_t length) const
+ {
+ std::vector<int, typename Rebind<Alloc, int>::type> vector(length*rand()/RAND_MAX);
+ return vector.size();
+ }
 };
 
 struct test_vector_dupe
 {
- template <class Alloc>
- int test(Alloc alloc, size_t length) const
- {
- typedef std::vector<int, typename Rebind<Alloc, int>::type> Vector;
- Vector vector(length*rand()/RAND_MAX);
- Vector dupe = vector;
- return dupe.size();
- }
+ template <class Alloc>
+ int test(Alloc alloc, size_t length) const
+ {
+ typedef std::vector<int, typename Rebind<Alloc, int>::type> Vector;
+ Vector vector(length*rand()/RAND_MAX);
+ Vector dupe = vector;
+ return dupe.size();
+ }
 };
 
 template <class Ty>
 struct test_vector_sort
 {
- template <class Alloc>
- int test(Alloc, size_t length) const
- {
- std::vector<Ty, typename Rebind<Alloc, Ty>::type> vector(length);
- for (size_t n = 0; n < length; ++n)
- vector[n] = length - n;
- sort(vector.begin(), vector.end());
- return 0;
- }
+ template <class Alloc>
+ int test(Alloc, size_t length) const
+ {
+ std::vector<Ty, typename Rebind<Alloc, Ty>::type> vector(length);
+ for (size_t n = 0; n < length; ++n)
+ vector[n] = length - n;
+ sort(vector.begin(), vector.end());
+ return 0;
+ }
 };
 
 struct test_vector_accumulate
 {
- template <class Alloc>
- int test(Alloc alloc, size_t length) const
- {
- std::vector<int, typename Rebind<Alloc, int>::type> vector(length*rand()/RAND_MAX);
- return accumulate(vector.begin(), vector.end(), 0);
- }
+ template <class Alloc>
+ int test(Alloc alloc, size_t length) const
+ {
+ std::vector<int, typename Rebind<Alloc, int>::type> vector(length*rand()/RAND_MAX);
+ return accumulate(vector.begin(), vector.end(), 0);
+ }
 };
 
 struct test_vector_accumulate_unaligned
 {
- template <class Alloc>
- int test(Alloc alloc, size_t length) const
- {
- std::vector<Unaligned, typename Rebind<Alloc, Unaligned>::type> vector(length);
- int total = 0;
- BOOST_FOREACH(Unaligned const &val, vector)
- {
- total += val.c[2];
- }
- return total;
- }
+ template <class Alloc>
+ int test(Alloc alloc, size_t length) const
+ {
+ std::vector<Unaligned, typename Rebind<Alloc, Unaligned>::type> vector(length);
+ int total = 0;
+ BOOST_FOREACH(Unaligned const &val, vector)
+ {
+ total += val.c[2];
+ }
+ return total;
+ }
 };
 
 template <class Ty>
 struct test_list_create
 {
- template <class Alloc>
- int test(Alloc alloc, size_t length) const
- {
- std::list<Ty, typename Rebind<Alloc, Ty>::type> list;
- fill_n(back_inserter(list), length, 42);
- return 0;
- }
+ template <class Alloc>
+ int test(Alloc alloc, size_t length) const
+ {
+ std::list<Ty, typename Rebind<Alloc, Ty>::type> list;
+ fill_n(back_inserter(list), length, 42);
+ return 0;
+ }
 };
 
 struct test_list_dupe
 {
- template <class Alloc>
- int test(Alloc alloc, size_t length) const
- {
- typedef std::list<int, typename Rebind<Alloc, int>::type> List;
- List list;
- fill_n(back_inserter(list), length, 42);
- List dupe = list;
- return dupe.size();
- }
+ template <class Alloc>
+ int test(Alloc alloc, size_t length) const
+ {
+ typedef std::list<int, typename Rebind<Alloc, int>::type> List;
+ List list;
+ fill_n(back_inserter(list), length, 42);
+ List dupe = list;
+ return dupe.size();
+ }
 };
 
 template <class Ty>
 struct test_list_sort
 {
- template <class Alloc>
- int test(Alloc alloc, size_t length) const
- {
- std::list<Ty, typename Rebind<Alloc, Ty>::type> list;
- for (size_t n = 0; n < length; ++n)
- list.push_back(length - n);
- list.sort();
- return 0;
- }
+ template <class Alloc>
+ int test(Alloc alloc, size_t length) const
+ {
+ std::list<Ty, typename Rebind<Alloc, Ty>::type> list;
+ for (size_t n = 0; n < length; ++n)
+ list.push_back(length - n);
+ list.sort();
+ return 0;
+ }
 };
 
 struct test_set_vector
 {
- template <class Alloc>
- int test(Alloc alloc, size_t length) const
- {
- typedef std::vector<int, typename Rebind<Alloc, int>::type> Vector;
- typedef std::set<Vector, std::less<Vector>, typename Rebind<Alloc, Vector>::type> Set;
- int dummy = 0;
- Set set;
- for (size_t n = 0; n < length; ++n)
- {
- size_t size = length*rand()/RAND_MAX;
- Vector vector(size);
- generate_n(back_inserter(vector), size, rand);
- set.insert(vector);
- dummy += set.size();
- }
- return dummy;
- }
+ template <class Alloc>
+ int test(Alloc alloc, size_t length) const
+ {
+ typedef std::vector<int, typename Rebind<Alloc, int>::type> Vector;
+ typedef std::set<Vector, std::less<Vector>, typename Rebind<Alloc, Vector>::type> Set;
+ int dummy = 0;
+ Set set;
+ for (size_t n = 0; n < length; ++n)
+ {
+ size_t size = length*rand()/RAND_MAX;
+ Vector vector(size);
+ generate_n(back_inserter(vector), size, rand);
+ set.insert(vector);
+ dummy += set.size();
+ }
+ return dummy;
+ }
 };
 
 template <class Map>
 int test_map_vector_impl(size_t length)
 {
- Map map;
- size_t mod = length/10;
- if (mod == 0)
- mod = 5;
- for (size_t n = 0; n < length; ++n)
- {
- int random = random_numbers[n] % mod;
- map[random].push_back(n);
- }
- return 0;
+ Map map;
+ size_t mod = length/10;
+ if (mod == 0)
+ mod = 5;
+ for (size_t n = 0; n < length; ++n)
+ {
+ int random = random_numbers[n] % mod;
+ map[random].push_back(n);
+ }
+ return 0;
 }
 
 template <class Ty>
 struct test_map_vector
 {
- template <class Alloc>
- int test(Alloc, size_t length) const
- {
- return test_map_vector_impl<std::map<int
- , std::vector<Ty, typename Rebind<Alloc, Ty>::type>
- , std::less<int>
- , typename Rebind<Alloc, int>::type> >(length);
- }
+ template <class Alloc>
+ int test(Alloc, size_t length) const
+ {
+ return test_map_vector_impl<std::map<int
+ , std::vector<Ty, typename Rebind<Alloc, Ty>::type>
+ , std::less<int>
+ , typename Rebind<Alloc, int>::type> >(length);
+ }
 };
 
 struct test_map_list_unaligned
 {
- template <class Alloc>
- int test(Alloc alloc, size_t length) const
- {
- std::map<int
- , std::list<Unaligned, typename Rebind<Alloc, Unaligned>::type>
- , std::less<int>
- , typename Rebind<Alloc, int>::type
- > map;
- size_t mod = length/10;
- for (size_t n = 0; n < length; ++n)
- {
- int random = random_numbers[n] % mod;
- map[random].push_back(n);
- }
- return 0;
- }
+ template <class Alloc>
+ int test(Alloc alloc, size_t length) const
+ {
+ std::map<int
+ , std::list<Unaligned, typename Rebind<Alloc, Unaligned>::type>
+ , std::less<int>
+ , typename Rebind<Alloc, int>::type
+ > map;
+ size_t mod = length/10;
+ for (size_t n = 0; n < length; ++n)
+ {
+ int random = random_numbers[n] % mod;
+ map[random].push_back(n);
+ }
+ return 0;
+ }
 };
 
 struct test_string_cat
 {
- template <class Alloc>
- int test(Alloc alloc, size_t length) const
- {
- typedef std::basic_string<char, std::char_traits<char>, typename Rebind<Alloc, char>::type> String;
- String str = "foo";
- for (size_t n = 0; n < length; ++n)
- {
- str += "bar";
- }
- return 0;
- }
+ template <class Alloc>
+ int test(Alloc alloc, size_t length) const
+ {
+ typedef std::basic_string<char, std::char_traits<char>, typename Rebind<Alloc, char>::type> String;
+ String str = "foo";
+ for (size_t n = 0; n < length; ++n)
+ {
+ str += "bar";
+ }
+ return 0;
+ }
 };
 
 struct test_list_string
 {
- template <class Alloc>
- int test(Alloc alloc, size_t length) const
- {
- typedef std::basic_string<char, std::char_traits<char>, typename Rebind<Alloc, char>::type> String;
- typedef std::list<String, typename Rebind<Alloc, String>::type> List;
- List list;
- for (size_t n = 0; n < length; ++n)
- {
- list.push_back(String("spam"));
- }
- return 0;
- }
+ template <class Alloc>
+ int test(Alloc alloc, size_t length) const
+ {
+ typedef std::basic_string<char, std::char_traits<char>, typename Rebind<Alloc, char>::type> String;
+ typedef std::list<String, typename Rebind<Alloc, String>::type> List;
+ List list;
+ for (size_t n = 0; n < length; ++n)
+ {
+ list.push_back(String("spam"));
+ }
+ return 0;
+ }
 };
 
 //Build a std::map of size n. Loop for O(n^2) iterations.
@@ -218,27 +218,27 @@
 //http://tinyurl.com/mp6sub
 struct test_map_erase
 {
- template <class Alloc>
- int test(Alloc alloc, size_t length) const
- {
- typedef std::map<int
- , int
- , std::less<int>
- , typename Rebind<Alloc, int>::type
- > Map;
- Map map;
- std::copy(random_pairs.begin(), random_pairs.begin() + length, inserter(map, map.begin()));
- size_t max_length = length*length;
- for (size_t n = 0; n < max_length; ++n)
- {
- map.insert(random_pairs[length + n]);
- int random_remove = random_numbers[n];
- typename Map::iterator iter = map.lower_bound(random_remove);
- if (iter != map.end())
- map.erase(iter);
- }
- return 0;
- }
+ template <class Alloc>
+ int test(Alloc alloc, size_t length) const
+ {
+ typedef std::map<int
+ , int
+ , std::less<int>
+ , typename Rebind<Alloc, int>::type
+ > Map;
+ Map map;
+ std::copy(random_pairs.begin(), random_pairs.begin() + length, inserter(map, map.begin()));
+ size_t max_length = length*length;
+ for (size_t n = 0; n < max_length; ++n)
+ {
+ map.insert(random_pairs[length + n]);
+ int random_remove = random_numbers[n];
+ typename Map::iterator iter = map.lower_bound(random_remove);
+ if (iter != map.end())
+ map.erase(iter);
+ }
+ return 0;
+ }
 };
 
 //EOF

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-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -31,19 +31,19 @@
 template <class II>
 bool is_sorted(II F, II L)
 {
- II G = F;
- for (++G; G != L; ++F, ++G)
- {
- if (*G < *F)
- return false;
- }
- return true;
+ II G = F;
+ for (++G; G != L; ++F, ++G)
+ {
+ if (*G < *F)
+ return false;
+ }
+ return true;
 }
 
 template <class Cont>
 bool is_sorted(Cont const &cont)
 {
- return is_sorted(boost::begin(cont), boost::end(cont));
+ return is_sorted(boost::begin(cont), boost::end(cont));
 }
 
 using namespace std;
@@ -61,126 +61,158 @@
 
 struct Tracked
 {
- static int count;
- Tracked()
- {
- ++count;
- std::cout << "T::T(): " << count << endl;
- }
- Tracked(Tracked const &)
- {
- ++count;
- std::cout << "T::T(T const &): " << count << endl;
- }
- Tracked &operator=(Tracked const &)
- {
- ++count;
- std::cout << "T &operator=(T const &): " << count << endl;
- return *this;
- }
- ~Tracked()
- {
- --count;
- std::cout << "T::~T(): " << count << endl;
- }
+ static int count;
+ Tracked()
+ {
+ ++count;
+ std::cout << "T::T(): " << count << endl;
+ }
+ Tracked(Tracked const &)
+ {
+ ++count;
+ std::cout << "T::T(T const &): " << count << endl;
+ }
+ Tracked &operator=(Tracked const &)
+ {
+ ++count;
+ std::cout << "T &operator=(T const &): " << count << endl;
+ return *this;
+ }
+ ~Tracked()
+ {
+ --count;
+ std::cout << "T::~T(): " << count << endl;
+ }
 };
 
 int Tracked::count = 0;
 
 BOOST_AUTO_TEST_CASE(test_stack)
 {
- monotonic::stack<> stack;
- {
- size_t top = stack.top();
- int &n2 = stack.push<int>();
- float &f0 = stack.push<float>();
- char &n3 = stack.push<char>();
- Tracked &tracked = stack.push<Tracked>();
- boost::array<int, 42> &a = stack.push_array<int, 42>();
-
- BOOST_ASSERT(stack.size() == 5);
-
- size_t peak = stack.top();
- cout << "STACK:" << endl;
- BOOST_FOREACH(monotonic::stack<>::value_type const &elem, stack)
- {
- cout << elem.get_type().name() << endl;
- }
- stack.pop();
- stack.pop();
- stack.pop();
- stack.pop();
- stack.pop();
- size_t top2 = stack.top();
- BOOST_ASSERT(top2 == top);
- BOOST_ASSERT(Tracked::count == 0);
- }
+ /*
+ monotonic::stack<> stack;
+ {
+ size_t top = stack.top();
+ int &n2 = stack.push<int>();
+ float &f0 = stack.push<float>();
+ char &n3 = stack.push<char>();
+ Tracked &tracked = stack.push<Tracked>();
+ boost::array<int, 42> &a = stack.push_array<int, 42>();
+
+ BOOST_ASSERT(stack.size() == 5);
+
+ size_t peak = stack.top();
+ cout << "STACK:" << endl;
+ BOOST_FOREACH(monotonic::stack<>::value_type const &elem, stack)
+ {
+ cout << elem.get_type().name() << endl;
+ }
+ stack.pop();
+ stack.pop();
+ stack.pop();
+ stack.pop();
+ stack.pop();
+ size_t top2 = stack.top();
+ BOOST_ASSERT(top2 == top);
+ BOOST_ASSERT(Tracked::count == 0);
+ }
+ */
+}
+
+BOOST_AUTO_TEST_CASE(test_fixed_stack)
+{
+ monotonic::fixed_stack<> stack;
+ {
+ size_t top = stack.top();
+ int &n2 = stack.push<int>();
+ float &f0 = stack.push<float>();
+ char &n3 = stack.push<char>();
+ Tracked &tracked = stack.push<Tracked>();
+ boost::array<int, 42> &a = stack.push_array<int, 42>();
+
+ BOOST_ASSERT(stack.size() == 5);
+
+ size_t peak = stack.top();
+ cout << "STACK:" << endl;
+ BOOST_FOREACH(monotonic::fixed_stack<>::value_type const &elem, stack)
+ {
+ cout << elem.get_type().name() << endl;
+ }
+ stack.pop();
+ stack.pop();
+ stack.pop();
+ stack.pop();
+ stack.pop();
+ size_t top2 = stack.top();
+ BOOST_ASSERT(top2 == top);
+ BOOST_ASSERT(Tracked::count == 0);
+ }
 }
 
 template <class Number>
 Number work(size_t iterations, std::vector<Number> const &data)
 {
- Number sum = 0;
- size_t size = data.size();
- for (size_t i = 0; i < iterations; ++i)
- {
- Number a = data[i % size];
- Number b = data[(i + 500)%size];
- sum += a * b;
- }
- return sum;
+ Number sum = 0;
+ size_t size = data.size();
+ for (size_t i = 0; i < iterations; ++i)
+ {
+ Number a = data[i % size];
+ Number b = data[(i + 500)%size];
+ sum += a * b;
+ }
+ return sum;
 }
 
 void test_floats()
 {
- size_t iterations = 1000*1000*100;
- size_t outter = 1;//00;//0*1000*10;
- double int_t = 0;
- double float_t = 0;
+ size_t iterations = 1000*1000*100;
+ size_t outter = 1;//00;//0*1000*10;
+ double int_t = 0;
+ double float_t = 0;
 
- size_t size = 100000;
- std::vector<int> ints(size);
+ size_t size = 100000;
+ std::vector<int> ints(size);
     srand(42);
- generate_n(ints.begin(), size, rand);
- std::vector<float> floats(size);
+ generate_n(ints.begin(), size, rand);
+ std::vector<float> floats(size);
     srand(42);
- generate_n(floats.begin(), size, rand);
+ generate_n(floats.begin(), size, rand);
 
- boost::timer int_timer;
- int int_sum = 0;
- for (size_t n = 0; n < outter; ++n)
- {
- int_sum += work(iterations, ints);
- }
- int_t = int_timer.elapsed();
- boost::timer float_timer;
- float float_sum = 0;
- for (size_t n = 0; n < outter; ++n)
- {
- float_sum += work(iterations, floats);
- }
- float_t = float_timer.elapsed();
- cout << int_t << ", " << float_t << "; " << int_sum << ", " << float_sum << endl;
+ boost::timer int_timer;
+ int int_sum = 0;
+ for (size_t n = 0; n < outter; ++n)
+ {
+ int_sum += work(iterations, ints);
+ }
+ int_t = int_timer.elapsed();
+ boost::timer float_timer;
+ float float_sum = 0;
+ for (size_t n = 0; n < outter; ++n)
+ {
+ float_sum += work(iterations, floats);
+ }
+ float_t = float_timer.elapsed();
+ cout << int_t << ", " << float_t << "; " << int_sum << ", " << float_sum << endl;
 }
 
 BOOST_AUTO_TEST_CASE(test_reclaimable)
 {
- std::vector<Tracked, monotonic::allocator<Tracked, heap_region_tag> > vec;
- monotonic::storage_base *store = &monotonic::static_storage<heap_region_tag>::get_storage();
- vec.resize(1);
- vec.erase(vec.begin());
- BOOST_ASSERT(Tracked::count == 0);
+ std::vector<Tracked, monotonic::allocator<Tracked, heap_region_tag> > vec;
+ monotonic::storage_base *store = &monotonic::static_storage<heap_region_tag>::get_storage();
+ vec.resize(1);
+ vec.erase(vec.begin());
+ BOOST_ASSERT(Tracked::count == 0);
 }
 
 BOOST_AUTO_TEST_CASE(test_interprocess_list)
 {
- monotonic::storage<> storage;
- {
- interprocess::list<int, monotonic::allocator<int> > list(storage);
- generate_n(back_inserter(list), 10, rand);
- list.sort();
- BOOST_ASSERT(is_sorted(list));
- }
+ monotonic::storage<> storage;
+ {
+ interprocess::list<int, monotonic::allocator<int> > list(storage);
+ generate_n(back_inserter(list), 10, rand);
+ list.sort();
+ BOOST_ASSERT(is_sorted(list));
+ }
 }
 
 // define some private regions
@@ -190,190 +222,190 @@
 BOOST_AUTO_TEST_CASE(test_set)
 {
 
- monotonic::storage<> storage;
- {
- monotonic::set<monotonic::vector<int> > set(storage);
- BOOST_ASSERT(set.get_allocator().get_storage() == &storage);
- set.insert(monotonic::vector<int>(storage));
- monotonic::vector<int> &v = *set.begin();
- BOOST_ASSERT(v.get_allocator().get_storage() == &storage);
+ monotonic::storage<> storage;
+ {
+ monotonic::set<monotonic::vector<int> > set(storage);
+ BOOST_ASSERT(set.get_allocator().get_storage() == &storage);
+ set.insert(monotonic::vector<int>(storage));
+ monotonic::vector<int> &v = *set.begin();
+ BOOST_ASSERT(v.get_allocator().get_storage() == &storage);
 
- }
+ }
 }
 
 BOOST_AUTO_TEST_CASE(test_string)
 {
- monotonic::string<> str1;
- monotonic::string<region0> str2;
- monotonic::string<region1> str3;
-
- str1 = "foo";
- str2 = "bar";
- str3 = "bar";
- BOOST_ASSERT(str2 == str3);
- str1 = str3;
- BOOST_ASSERT(str1 == str3);
-
- 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);
- }
+ monotonic::string<> str1;
+ monotonic::string<region0> str2;
+ monotonic::string<region1> str3;
+
+ str1 = "foo";
+ str2 = "bar";
+ str3 = "bar";
+ BOOST_ASSERT(str2 == str3);
+ str1 = str3;
+ BOOST_ASSERT(str1 == str3);
+
+ 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)
 {
- monotonic::map<int, monotonic::string<region0>, region1> map;
- map[1] = "foo";
- map[2] = "bar";
-
- monotonic::static_storage<region0>::release();
- monotonic::static_storage<region1>::release();
-
-
- monotonic::storage<> storage;
- {
- monotonic::map<int, monotonic::list<int> > local_map(storage);
- BOOST_ASSERT(local_map.get_allocator().get_storage() == &storage);
-
- local_map[1].push_back(42);
-
- BOOST_ASSERT(local_map.get_allocator() == local_map[1].get_allocator());
- }
+ monotonic::map<int, monotonic::string<region0>, region1> map;
+ map[1] = "foo";
+ map[2] = "bar";
+
+ monotonic::static_storage<region0>::release();
+ monotonic::static_storage<region1>::release();
+
+
+ monotonic::storage<> storage;
+ {
+ monotonic::map<int, monotonic::list<int> > local_map(storage);
+ BOOST_ASSERT(local_map.get_allocator().get_storage() == &storage);
+
+ local_map[1].push_back(42);
+
+ BOOST_ASSERT(local_map.get_allocator() == local_map[1].get_allocator());
+ }
 }
 
 BOOST_AUTO_TEST_CASE(test_vector)
 {
- monotonic::vector<int> vec;
- vec.resize(100);
- fill_n(vec.begin(), 100, 42);
-
- monotonic::vector<int, region1> vec2;
- vec2.resize(100);
- fill_n(vec2.begin(), 100, 42);
-
- BOOST_ASSERT(vec == vec2);
- BOOST_ASSERT(!(vec2 != vec));
- BOOST_ASSERT(!(vec < vec2));
- BOOST_ASSERT(!(vec2 < vec));
-
- vec2[0] = 40;
- BOOST_ASSERT(vec2 != vec);
- 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);
- }
+ monotonic::vector<int> vec;
+ vec.resize(100);
+ fill_n(vec.begin(), 100, 42);
+
+ monotonic::vector<int, region1> vec2;
+ vec2.resize(100);
+ fill_n(vec2.begin(), 100, 42);
+
+ BOOST_ASSERT(vec == vec2);
+ BOOST_ASSERT(!(vec2 != vec));
+ BOOST_ASSERT(!(vec < vec2));
+ BOOST_ASSERT(!(vec2 < vec));
+
+ vec2[0] = 40;
+ BOOST_ASSERT(vec2 != vec);
+ 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);
+ }
 }
 
 // why does this stall the unit-tests? after this, other tests are not run...
 
 BOOST_AUTO_TEST_CASE(test_list)
 {
- monotonic::list<int> cont;
- fill_n(back_inserter(cont), 100, 42);
+ monotonic::list<int> cont;
+ fill_n(back_inserter(cont), 100, 42);
 
- monotonic::list<int, region1> cont2;
- fill_n(back_inserter(cont2), 100, 42);
+ monotonic::list<int, region1> cont2;
+ fill_n(back_inserter(cont2), 100, 42);
 
- BOOST_ASSERT(cont == cont2);
- BOOST_ASSERT(!(cont != cont2));
- BOOST_ASSERT(!(cont < cont2));
- cont.front() = 5;
- BOOST_ASSERT(cont2 != cont);
- BOOST_ASSERT(cont < cont2);
- BOOST_ASSERT(!(cont2 < cont));
-
- monotonic::static_storage<>::reset();
- monotonic::static_storage<region1>::reset();
-
- monotonic::storage<> storage;
- {
- monotonic::list<monotonic::list<int> > list(storage);
- BOOST_ASSERT(list.get_allocator().get_storage() == &storage);
- list.push_back(monotonic::list<int>());
- BOOST_ASSERT(list.get_allocator().get_storage() == list.front().get_allocator().get_storage());
- //generate_n(back_inserter(list.front()), 100, rand);
- //BOOST_ASSERT(!is_sorted(list.front()));
- //size_t used_before = storage.used();
- //list.front().sort();
- //size_t used_after = storage.used();
- //BOOST_ASSERT(used_after > used_before);
- //BOOST_ASSERT(is_sorted(list.front()));
- }
+ BOOST_ASSERT(cont == cont2);
+ BOOST_ASSERT(!(cont != cont2));
+ BOOST_ASSERT(!(cont < cont2));
+ cont.front() = 5;
+ BOOST_ASSERT(cont2 != cont);
+ BOOST_ASSERT(cont < cont2);
+ BOOST_ASSERT(!(cont2 < cont));
+
+ monotonic::static_storage<>::reset();
+ monotonic::static_storage<region1>::reset();
+
+ monotonic::storage<> storage;
+ {
+ monotonic::list<monotonic::list<int> > list(storage);
+ BOOST_ASSERT(list.get_allocator().get_storage() == &storage);
+ list.push_back(monotonic::list<int>());
+ BOOST_ASSERT(list.get_allocator().get_storage() == list.front().get_allocator().get_storage());
+ //generate_n(back_inserter(list.front()), 100, rand);
+ //BOOST_ASSERT(!is_sorted(list.front()));
+ //size_t used_before = storage.used();
+ //list.front().sort();
+ //size_t used_after = storage.used();
+ //BOOST_ASSERT(used_after > used_before);
+ //BOOST_ASSERT(is_sorted(list.front()));
+ }
 }
 
 BOOST_AUTO_TEST_CASE(test_deque)
 {
- monotonic::deque<int, region0> deq0;
- monotonic::deque<int, region1> deq1;
+ monotonic::deque<int, region0> deq0;
+ monotonic::deque<int, region1> deq1;
 
- deq0.push_back(42);
- deq1.push_back(42);
- BOOST_ASSERT(deq0 == deq1);
+ deq0.push_back(42);
+ deq1.push_back(42);
+ BOOST_ASSERT(deq0 == deq1);
 
- monotonic::static_storage<region0>::reset();
- monotonic::static_storage<region1>::reset();
+ monotonic::static_storage<region0>::reset();
+ monotonic::static_storage<region1>::reset();
 }
 
 
 BOOST_AUTO_TEST_CASE(test_chain)
 {
- monotonic::chain<int, 16, region0> deq0;
- monotonic::chain<int, 16, region1> deq1;
+ monotonic::chain<int, 16, region0> deq0;
+ monotonic::chain<int, 16, region1> deq1;
 
- deq0.push_back(1);
- deq1.push_back(1);
- BOOST_ASSERT(deq0 == deq1);
-
- deq1.push_back(2);
- deq1.push_back(3);
- BOOST_ASSERT(deq0 != deq1);
-
- int sum = 0;
- BOOST_FOREACH(int n, deq1)
- sum += n;
- BOOST_CHECK(sum == 6);
-
- monotonic::static_storage<region0>::reset();
- monotonic::static_storage<region1>::reset();
+ deq0.push_back(1);
+ deq1.push_back(1);
+ BOOST_ASSERT(deq0 == deq1);
+
+ deq1.push_back(2);
+ deq1.push_back(3);
+ BOOST_ASSERT(deq0 != deq1);
+
+ int sum = 0;
+ BOOST_FOREACH(int n, deq1)
+ sum += n;
+ BOOST_CHECK(sum == 6);
+
+ monotonic::static_storage<region0>::reset();
+ monotonic::static_storage<region1>::reset();
 }
 
 BOOST_AUTO_TEST_CASE(test_local)
 {
- monotonic::local<region0> storage0;
- monotonic::local<region1> storage1;
- {
- std::list<int, monotonic::allocator<int, region0> > list0;
- std::list<int, monotonic::allocator<int, region1> > list1;
- fill_n(back_inserter(list0), 100, 42);
- fill_n(back_inserter(list1), 100, 42);
-
- monotonic::string<region0> str("foo");
- str += "bar";
- BOOST_ASSERT(str == "foobar");
- }
+ monotonic::local<region0> storage0;
+ monotonic::local<region1> storage1;
+ {
+ std::list<int, monotonic::allocator<int, region0> > list0;
+ std::list<int, monotonic::allocator<int, region1> > list1;
+ fill_n(back_inserter(list0), 100, 42);
+ fill_n(back_inserter(list1), 100, 42);
+
+ monotonic::string<region0> str("foo");
+ str += "bar";
+ BOOST_ASSERT(str == "foobar");
+ }
 }
 
 //struct region0 {};
@@ -381,233 +413,233 @@
 
 BOOST_AUTO_TEST_CASE(test_shared_allocation)
 {
- //// use default region and access
- //std::list<int, monotonic::allocator<int> > list;
+ //// use default region and access
+ //std::list<int, monotonic::allocator<int> > list;
 
- //// use specific region and access
- //std::list<int, monotonic::allocator<int, region0, monotonic::shared_access_tag> > list;
- //std::list<int, monotonic::allocator<int, region0, monotonic::thread_local_access_tag> > list;
-
- //// using wrapped container
- //monotonic::list<int> list;
- //monotonic::list<int, region0, monotonic::shared_access_tag> list;
- //monotonic::list<int, region0, monotonic::thread_local_access_tag> list;
+ //// use specific region and access
+ //std::list<int, monotonic::allocator<int, region0, monotonic::shared_access_tag> > list;
+ //std::list<int, monotonic::allocator<int, region0, monotonic::thread_local_access_tag> > list;
+
+ //// using wrapped container
+ //monotonic::list<int> list;
+ //monotonic::list<int, region0, monotonic::shared_access_tag> list;
+ //monotonic::list<int, region0, monotonic::thread_local_access_tag> list;
 
- //// use different regions
- //monotonic::map<int, monotonic::list<monotonic::string, region1>, region0> map;
+ //// use different regions
+ //monotonic::map<int, monotonic::list<monotonic::string, region1>, region0> map;
 }
 
 BOOST_AUTO_TEST_CASE(test_regional_allocation)
 {
- typedef std::list<int, monotonic::allocator<int, region0> > List0;
- typedef std::list<int, monotonic::allocator<int, region1> > List1;
- {
- List0 list0;
- generate_n(back_inserter(list0), 10, rand);
- list0.sort();
-
- List1 list1;
- generate_n(back_inserter(list1), 10, rand);
- list1.sort();
- }
+ typedef std::list<int, monotonic::allocator<int, region0> > List0;
+ typedef std::list<int, monotonic::allocator<int, region1> > List1;
+ {
+ List0 list0;
+ generate_n(back_inserter(list0), 10, rand);
+ list0.sort();
+
+ List1 list1;
+ generate_n(back_inserter(list1), 10, rand);
+ list1.sort();
+ }
 }
 
 
 BOOST_AUTO_TEST_CASE(test_local_storage)
 {
- monotonic::storage<10*1024> storage;
- {
- storage.allocate_bytes(123);
- BOOST_ASSERT(storage.fixed_used() == 123);
- BOOST_ASSERT(storage.heap_used() == 0);
- BOOST_ASSERT(storage.used() == 123);
-
- storage.reset();
- BOOST_ASSERT(storage.fixed_used() == 0);
- BOOST_ASSERT(storage.heap_used() == 0);
- BOOST_ASSERT(storage.used() == 0);
-
- // test alignment
- storage.reset();
- storage.allocate_bytes(12, 16);
-
- storage.allocate_bytes(12, 64);
- storage.reset();
- }
+ monotonic::storage<10*1024> storage;
+ {
+ storage.allocate_bytes(123);
+ BOOST_ASSERT(storage.fixed_used() == 123);
+ BOOST_ASSERT(storage.heap_used() == 0);
+ BOOST_ASSERT(storage.used() == 123);
+
+ storage.reset();
+ BOOST_ASSERT(storage.fixed_used() == 0);
+ BOOST_ASSERT(storage.heap_used() == 0);
+ BOOST_ASSERT(storage.used() == 0);
+
+ // test alignment
+ storage.reset();
+ storage.allocate_bytes(12, 16);
+
+ storage.allocate_bytes(12, 64);
+ storage.reset();
+ }
 }
 
 BOOST_AUTO_TEST_CASE(test_local_storage_to_heap)
 {
- return;
- monotonic::storage<16> storage;
- {
- storage.allocate_bytes(16);
- BOOST_ASSERT(storage.heap_used() == 0);
-
- storage.allocate_bytes(200);
- BOOST_ASSERT(storage.heap_used() == 200);
-
- storage.release();
-
- BOOST_ASSERT(storage.used() == 0);
- storage.allocate_bytes<2000>();
- BOOST_ASSERT(storage.fixed_used() == 0);
- BOOST_ASSERT(storage.heap_used() == 2000);
-
- storage.allocate_bytes<10>();
- BOOST_ASSERT(storage.fixed_used() == 10);
- BOOST_ASSERT(storage.heap_used() == 2000);
- }
+ return;
+ monotonic::storage<16> storage;
+ {
+ storage.allocate_bytes(16);
+ BOOST_ASSERT(storage.heap_used() == 0);
+
+ storage.allocate_bytes(200);
+ BOOST_ASSERT(storage.heap_used() == 200);
+
+ storage.release();
+
+ BOOST_ASSERT(storage.used() == 0);
+ storage.allocate_bytes<2000>();
+ BOOST_ASSERT(storage.fixed_used() == 0);
+ BOOST_ASSERT(storage.heap_used() == 2000);
+
+ storage.allocate_bytes<10>();
+ BOOST_ASSERT(storage.fixed_used() == 10);
+ BOOST_ASSERT(storage.heap_used() == 2000);
+ }
 }
 
 BOOST_AUTO_TEST_CASE(test_local_storage_iter)
 {
- size_t length = 4;
- // storage starts on the stack (in this case, 10k of it), then merges into the heap as needed
- monotonic::storage<10*1024> storage;
- for (size_t n = 0; n < length; ++n)
- {
- // create a new int from storage
- int &n0 = storage.create<int>();
-
- // create a new string (uses correct alignment)
- string const &s1 = storage.create<string>("foo");
- BOOST_ASSERT(s1 == "foo");
-
- // allocate 37 bytes with alignment 1
- char *array0 = storage.allocate_bytes(37);
- fill_n(array0, 37, 42);
-
- // allocate 2537 bytes with 64-byte alignment
- char *array1 = storage.allocate_bytes(2537, 64);
- fill_n(array1, 2537, 123);
-
- // allocate 1283 bytes with machine alignment
- char *array2 = storage.allocate_bytes<1283>();
- fill_n(array2, 1283, 42);
-
- array<int, 42> &array3 = storage.create<array<int, 42> >();
-
- // destroy objects. this only calls the destructors; it does not release memory
- storage.destroy(s1);
-
- //cout << "storage.fixed, heap, total used: " << storage.fixed_used() << ", " << storage.heap_used() << ", " << storage.used() << endl;
- }
- // storage is released. if this was only ever on the stack, no work is done
+ size_t length = 4;
+ // storage starts on the stack (in this case, 10k of it), then merges into the heap as needed
+ monotonic::storage<10*1024> storage;
+ for (size_t n = 0; n < length; ++n)
+ {
+ // create a new int from storage
+ int &n0 = storage.create<int>();
+
+ // create a new string (uses correct alignment)
+ string const &s1 = storage.create<string>("foo");
+ BOOST_ASSERT(s1 == "foo");
+
+ // allocate 37 bytes with alignment 1
+ char *array0 = storage.allocate_bytes(37);
+ fill_n(array0, 37, 42);
+
+ // allocate 2537 bytes with 64-byte alignment
+ char *array1 = storage.allocate_bytes(2537, 64);
+ fill_n(array1, 2537, 123);
+
+ // allocate 1283 bytes with machine alignment
+ char *array2 = storage.allocate_bytes<1283>();
+ fill_n(array2, 1283, 42);
+
+ array<int, 42> &array3 = storage.create<array<int, 42> >();
+
+ // destroy objects. this only calls the destructors; it does not release memory
+ storage.destroy(s1);
+
+ //cout << "storage.fixed, heap, total used: " << storage.fixed_used() << ", " << storage.heap_used() << ", " << storage.used() << endl;
+ }
+ // storage is released. if this was only ever on the stack, no work is done
 }
 
 BOOST_AUTO_TEST_CASE(test_ctors)
 {
- string foo = "foo";
- {
- monotonic::vector<char> v1(foo.begin(), foo.end());
- BOOST_CHECK(v1.size() == 3);
- BOOST_CHECK(equal(v1.begin(), v1.end(), "foo"));
-
- monotonic::vector<char> v2(6, 'x');
- BOOST_CHECK(v2.size() == 6);
- BOOST_CHECK(equal(v2.begin(), v2.end(), "xxxxxx"));
-
- monotonic::set<char> s2(foo.begin(), foo.end());
- BOOST_CHECK(s2.size() == 2);
- BOOST_CHECK(s2.find('f') != s2.end());
- BOOST_CHECK(s2.find('o') != s2.end());
-
- monotonic::vector<pair<int, string> > v;
- v.push_back(make_pair(42,"foo"));
- v.push_back(make_pair(123,"bar"));
-
- monotonic::map<int, string> m1(v.begin(), v.end());
- BOOST_CHECK(m1.find(42) != m1.end());
- BOOST_CHECK(m1.find(123) != m1.end());
-
- monotonic::list<int> l1(foo.begin(), foo.end());
- BOOST_CHECK(equal(l1.begin(), l1.end(), "foo"));
- }
- monotonic::reset_storage();
+ string foo = "foo";
+ {
+ monotonic::vector<char> v1(foo.begin(), foo.end());
+ BOOST_CHECK(v1.size() == 3);
+ BOOST_CHECK(equal(v1.begin(), v1.end(), "foo"));
+
+ monotonic::vector<char> v2(6, 'x');
+ BOOST_CHECK(v2.size() == 6);
+ BOOST_CHECK(equal(v2.begin(), v2.end(), "xxxxxx"));
+
+ monotonic::set<char> s2(foo.begin(), foo.end());
+ BOOST_CHECK(s2.size() == 2);
+ BOOST_CHECK(s2.find('f') != s2.end());
+ BOOST_CHECK(s2.find('o') != s2.end());
+
+ monotonic::vector<pair<int, string> > v;
+ v.push_back(make_pair(42,"foo"));
+ v.push_back(make_pair(123,"bar"));
+
+ monotonic::map<int, string> m1(v.begin(), v.end());
+ BOOST_CHECK(m1.find(42) != m1.end());
+ BOOST_CHECK(m1.find(123) != m1.end());
+
+ monotonic::list<int> l1(foo.begin(), foo.end());
+ BOOST_CHECK(equal(l1.begin(), l1.end(), "foo"));
+ }
+ monotonic::reset_storage();
 }
 
 BOOST_AUTO_TEST_CASE( test_copy )
 {
- monotonic::storage<> storage;
- monotonic::vector<int> v1(storage);
+ monotonic::storage<> storage;
+ monotonic::vector<int> v1(storage);
 
- for (int n = 0; n < 100; ++n)
- v1.push_back(n);
+ for (int n = 0; n < 100; ++n)
+ v1.push_back(n);
 
- size_t rem1 = storage.fixed_remaining();
- monotonic::vector<int> v2(v1);
- size_t rem2 = storage.fixed_remaining();
+ size_t rem1 = storage.fixed_remaining();
+ monotonic::vector<int> v2(v1);
+ size_t rem2 = storage.fixed_remaining();
 
- //BOOST_CHECK(v2 == v1);
- //BOOST_CHECK_EQUAL(rem1 - rem2, 12 + 100*sizeof(int));
+ //BOOST_CHECK(v2 == v1);
+ //BOOST_CHECK_EQUAL(rem1 - rem2, 12 + 100*sizeof(int));
 }
 
 BOOST_AUTO_TEST_CASE(test_shared_allocators)
 {
- monotonic::storage<> sa, sb;
- {
- monotonic::vector<int> v0(sa), v1(sa);
- monotonic::vector<int> v2(sb), v3(sb);
- monotonic::list<int> l0(sa), l1(sb);
-
- BOOST_CHECK(v0.get_allocator() == v1.get_allocator());
- BOOST_CHECK(v2.get_allocator() == v3.get_allocator());
- BOOST_CHECK(v0.get_allocator() != v2.get_allocator());
- BOOST_CHECK(v3.get_allocator() != v1.get_allocator());
-
- for (int n = 0; n < 10; ++n)
- v0.push_back(n);
-
- v1 = v0;
- v1.swap(v2); // swap from different allocators means they are copied
- BOOST_CHECK(v1.empty() && v3.empty() && v1 == v3);
-
- BOOST_CHECK(v2 == v0); // both are now [0..9]
-
- v1.swap(v0); // swap from same allocators means no copying
- BOOST_CHECK(v2 == v1);
- BOOST_CHECK(v0 == v3);
-
- //l0.assign(v0.begin(), v0.end());
- //l1 = l0;
- //BOOST_CHECK(l0 == l1);
- }
+ monotonic::storage<> sa, sb;
+ {
+ monotonic::vector<int> v0(sa), v1(sa);
+ monotonic::vector<int> v2(sb), v3(sb);
+ monotonic::list<int> l0(sa), l1(sb);
+
+ BOOST_CHECK(v0.get_allocator() == v1.get_allocator());
+ BOOST_CHECK(v2.get_allocator() == v3.get_allocator());
+ BOOST_CHECK(v0.get_allocator() != v2.get_allocator());
+ BOOST_CHECK(v3.get_allocator() != v1.get_allocator());
+
+ for (int n = 0; n < 10; ++n)
+ v0.push_back(n);
+
+ v1 = v0;
+ v1.swap(v2); // swap from different allocators means they are copied
+ BOOST_CHECK(v1.empty() && v3.empty() && v1 == v3);
+
+ BOOST_CHECK(v2 == v0); // both are now [0..9]
+
+ v1.swap(v0); // swap from same allocators means no copying
+ BOOST_CHECK(v2 == v1);
+ BOOST_CHECK(v0 == v3);
+
+ //l0.assign(v0.begin(), v0.end());
+ //l1 = l0;
+ //BOOST_CHECK(l0 == l1);
+ }
 }
 
 BOOST_AUTO_TEST_CASE(test_basic)
 {
- monotonic::storage<> storage;
- {
- monotonic::vector<int> v1(storage);
-
- for(int i = 0; i < 100; ++i)
- v1.push_back(i);
-
- monotonic::vector<int> copy(storage);
- size_t len = storage.used();
- copy = v1;
- size_t len2 = storage.used();
-
- BOOST_CHECK(copy == v1);
-
- // create a list that uses inline, monotonically-increasing storage
- monotonic::list<int> list(storage);
- list.push_back(100);
- list.push_back(400);
- list.erase(list.begin());
-
- // a map from the same storage
- monotonic::map<int, float> map(storage);
- map[42] = 3.14f;
- BOOST_CHECK(map[42] == 3.14f);
-
- // a set...
- monotonic::set<float> set(storage);
- set.insert(3.14f);
- set.insert(-123.f);
- BOOST_CHECK(set.size() == 2);
- }
+ monotonic::storage<> storage;
+ {
+ monotonic::vector<int> v1(storage);
+
+ for(int i = 0; i < 100; ++i)
+ v1.push_back(i);
+
+ monotonic::vector<int> copy(storage);
+ size_t len = storage.used();
+ copy = v1;
+ size_t len2 = storage.used();
+
+ BOOST_CHECK(copy == v1);
+
+ // create a list that uses inline, monotonically-increasing storage
+ monotonic::list<int> list(storage);
+ list.push_back(100);
+ list.push_back(400);
+ list.erase(list.begin());
+
+ // a map from the same storage
+ monotonic::map<int, float> map(storage);
+ map[42] = 3.14f;
+ BOOST_CHECK(map[42] == 3.14f);
+
+ // a set...
+ monotonic::set<float> set(storage);
+ set.insert(3.14f);
+ set.insert(-123.f);
+ BOOST_CHECK(set.size() == 2);
+ }
 }
 
 //EOF

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-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -34,103 +34,103 @@
 template <class Fun>
 PoolResult run_test(size_t count, size_t length, Fun fun, Type types)
 {
- typedef Allocator<Type::FastPool, int> fast_pool_alloc;
- typedef Allocator<Type::Pool, int> pool_alloc;
- typedef Allocator<Type::Monotonic, int> mono_alloc;
- typedef Allocator<Type::TBB, int> tbb_alloc;
- typedef Allocator<Type::Standard, int> std_alloc;
-
- PoolResult result;
-
- if (types.Includes(Type::TBB))
- {
- srand(42);
- boost::timer timer;
- for (size_t n = 0; n < count; ++n)
- {
- {
- fun.test(tbb_alloc(), length);
- }
- }
- result.tbb_elapsed = timer.elapsed();
- }
-
- if (types.Includes(Type::FastPool))
- {
- srand(42);
- boost::timer timer;
- for (size_t n = 0; n < count; ++n)
- {
- {
- fun.test(fast_pool_alloc(), length);
- }
- boost::singleton_pool<boost::fast_pool_allocator_tag, sizeof(int)>::release_memory();
- boost::singleton_pool<boost::fast_pool_allocator_tag, sizeof(Unaligned)>::release_memory();
- // CJS ?? how to release memory created by a rebind<>'d fast_pool_allocator, such as xtree::rebind ??
- }
- result.fast_pool_elapsed = timer.elapsed();
- }
-
- if (types.Includes(Type::Pool))
- {
- srand(42);
- boost::timer timer;
- for (size_t n = 0; n < count; ++n)
- {
- {
- fun.test(pool_alloc(), length);
- }
- boost::singleton_pool<boost::pool_allocator_tag, sizeof(int)>::release_memory();
- boost::singleton_pool<boost::pool_allocator_tag, sizeof(Unaligned)>::release_memory();
- // CJS ?? how to release memory created by a rebind<>'d pool_allocator, such as xtree::rebind ??
- }
- result.pool_elapsed = timer.elapsed();
- }
-
- if (types.Includes(Type::Monotonic))
- {
- srand(42);
- boost::timer timer;
- for (size_t n = 0; n < count; ++n)
- {
- {
- fun.test(mono_alloc(), length);
- }
- boost::monotonic::reset_storage();
- }
- result.mono_elapsed = timer.elapsed();
- }
-
- if (types.Includes(Type::Monotonic))
- {
- srand(42);
- monotonic::local<my_local> storage;
- boost::timer timer;
- for (size_t n = 0; n < count; ++n)
- {
- {
- fun.test(monotonic::allocator<void, my_local>(), length);
- }
- storage.reset();
- }
- result.local_mono_elapsed = timer.elapsed();
- }
-
- if (types.Includes(Type::Standard))
- {
- srand(42);
- boost::timer timer;
- for (size_t n = 0; n < count; ++n)
- {
- {
- fun.test(std_alloc(), length);
- }
- }
- result.std_elapsed = timer.elapsed();
- }
+ typedef Allocator<Type::FastPool, int> fast_pool_alloc;
+ typedef Allocator<Type::Pool, int> pool_alloc;
+ typedef Allocator<Type::Monotonic, int> mono_alloc;
+ typedef Allocator<Type::TBB, int> tbb_alloc;
+ typedef Allocator<Type::Standard, int> std_alloc;
+
+ PoolResult result;
+
+ if (types.Includes(Type::TBB))
+ {
+ srand(42);
+ boost::timer timer;
+ for (size_t n = 0; n < count; ++n)
+ {
+ {
+ fun.test(tbb_alloc(), length);
+ }
+ }
+ result.tbb_elapsed = timer.elapsed();
+ }
+
+ if (types.Includes(Type::FastPool))
+ {
+ srand(42);
+ boost::timer timer;
+ for (size_t n = 0; n < count; ++n)
+ {
+ {
+ fun.test(fast_pool_alloc(), length);
+ }
+ boost::singleton_pool<boost::fast_pool_allocator_tag, sizeof(int)>::release_memory();
+ boost::singleton_pool<boost::fast_pool_allocator_tag, sizeof(Unaligned)>::release_memory();
+ // CJS ?? how to release memory created by a rebind<>'d fast_pool_allocator, such as xtree::rebind ??
+ }
+ result.fast_pool_elapsed = timer.elapsed();
+ }
+
+ if (types.Includes(Type::Pool))
+ {
+ srand(42);
+ boost::timer timer;
+ for (size_t n = 0; n < count; ++n)
+ {
+ {
+ fun.test(pool_alloc(), length);
+ }
+ boost::singleton_pool<boost::pool_allocator_tag, sizeof(int)>::release_memory();
+ boost::singleton_pool<boost::pool_allocator_tag, sizeof(Unaligned)>::release_memory();
+ // CJS ?? how to release memory created by a rebind<>'d pool_allocator, such as xtree::rebind ??
+ }
+ result.pool_elapsed = timer.elapsed();
+ }
+
+ if (types.Includes(Type::Monotonic))
+ {
+ srand(42);
+ boost::timer timer;
+ for (size_t n = 0; n < count; ++n)
+ {
+ {
+ fun.test(mono_alloc(), length);
+ }
+ boost::monotonic::reset_storage();
+ }
+ result.mono_elapsed = timer.elapsed();
+ }
+
+ if (types.Includes(Type::Monotonic))
+ {
+ srand(42);
+ monotonic::local<my_local> storage;
+ boost::timer timer;
+ for (size_t n = 0; n < count; ++n)
+ {
+ {
+ fun.test(monotonic::allocator<void, my_local>(), length);
+ }
+ storage.reset();
+ }
+ result.local_mono_elapsed = timer.elapsed();
+ }
+
+ if (types.Includes(Type::Standard))
+ {
+ srand(42);
+ boost::timer timer;
+ for (size_t n = 0; n < count; ++n)
+ {
+ {
+ fun.test(std_alloc(), length);
+ }
+ }
+ result.std_elapsed = timer.elapsed();
+ }
 
- cout << "." << flush;
- return result;
+ cout << "." << flush;
+ return result;
 }
 
 // these are guaranteed to be at least length + length*length long
@@ -139,27 +139,27 @@
 
 std::pair<int, int> random_pair()
 {
- return make_pair(rand(), rand());
+ return make_pair(rand(), rand());
 }
 
 template <class Fun>
 PoolResults run_tests(size_t count, size_t max_length, size_t num_iterations, const char *title, Fun fun, Type types = Type::TBB | Type::Standard | Type::Monotonic)
 {
- boost::timer timer;
- cout << title << ": reps=" << count << ", len=" << max_length << ", steps=" << num_iterations;
- PoolResults results;
- srand(42);
- for (size_t length = 10; length < max_length; length += max_length/num_iterations)
- {
- size_t required = length + length*length;
- if (random_numbers.size() < required)
- generate_n(back_inserter(random_numbers), required - random_numbers.size(), rand);
- if (random_pairs.size() < required)
- generate_n(back_inserter(random_pairs), required - random_pairs.size(), random_pair);
- results[length] = run_test(count, length, fun, types);
- }
- cout << endl << "took " << timer.elapsed() << "s" << endl;
- return results;
+ boost::timer timer;
+ cout << title << ": reps=" << count << ", len=" << max_length << ", steps=" << num_iterations;
+ PoolResults results;
+ srand(42);
+ for (size_t length = 10; length < max_length; length += max_length/num_iterations)
+ {
+ size_t required = length + length*length;
+ if (random_numbers.size() < required)
+ generate_n(back_inserter(random_numbers), required - random_numbers.size(), rand);
+ if (random_pairs.size() < required)
+ generate_n(back_inserter(random_pairs), required - random_pairs.size(), random_pair);
+ results[length] = run_test(count, length, fun, types);
+ }
+ cout << endl << "took " << timer.elapsed() << "s" << endl;
+ return results;
 }
 
 std::vector<PoolResult> cumulative;
@@ -170,99 +170,99 @@
 template <class II>
 typename boost::iterator_value<II>::type calc_mean(II first, II last, size_t num)
 {
- return std::accumulate(first, last, typename boost::iterator_value<II>::type(0))*(1.0/num);
+ return std::accumulate(first, last, typename boost::iterator_value<II>::type(0))*(1.0/num);
 }
 
 template <class II>
 typename boost::iterator_value<II>::type calc_mean(II first, II last)
 {
- if (first == last)
- throw std::range_error("calc_mean");
- return calc_mean(first, last, std::distance(first, last));
+ if (first == last)
+ throw std::range_error("calc_mean");
+ return calc_mean(first, last, std::distance(first, last));
 }
 
 template <class II>
 std::pair<typename boost::iterator_value<II>::type,typename boost::iterator_value<II>::type> standard_deviation_mean(II first, II last)
 {
- typedef typename boost::iterator_value<II>::type Value;
- size_t length = std::distance(first, last);
- if (length == 0)
- throw std::range_error("standard_deviation_mean");
- Value mean = calc_mean(first, last, length);
- Value std_dev = 0;
- for (; first != last; ++first)
- {
- Value val = *first - mean;
- std_dev += val*val;
- }
- std_dev = sqrt(std_dev*(1./length));
- return std::make_pair(std_dev, mean);
+ typedef typename boost::iterator_value<II>::type Value;
+ size_t length = std::distance(first, last);
+ if (length == 0)
+ throw std::range_error("standard_deviation_mean");
+ Value mean = calc_mean(first, last, length);
+ Value std_dev = 0;
+ for (; first != last; ++first)
+ {
+ Value val = *first - mean;
+ std_dev += val*val;
+ }
+ std_dev = sqrt(std_dev*(1./length));
+ return std::make_pair(std_dev, mean);
 }
 
 template <class Cont>
 std::pair<typename Cont::value_type, typename Cont::value_type> standard_deviation_mean(Cont const &cont)
 {
- return standard_deviation_mean(boost::begin(cont), boost::end(cont));
+ return standard_deviation_mean(boost::begin(cont), boost::end(cont));
 }
 
 void print_cumulative(std::vector<PoolResult> const &results)
 {
- pair<PoolResult, PoolResult> dev_mean = standard_deviation_mean(results);
- size_t w = 10;
- cout << setw(w) << "scheme" << setw(w) << "mean" << setw(w) << "std-dev" << setw(w) << "min" << setw(w) << "max" << endl;
- cout << setw(w) << "fast" << setprecision(3) << setw(w) << dev_mean.second.fast_pool_elapsed << setw(w) << dev_mean.first.fast_pool_elapsed << setw(w) << result_min.fast_pool_elapsed << setw(w) << result_max.fast_pool_elapsed << endl;
- cout << setw(w) << "pool" << setprecision(3) << setw(w) << dev_mean.second.pool_elapsed << setw(w) << dev_mean.first.pool_elapsed << setw(w) << result_min.pool_elapsed << setw(w) << result_max.pool_elapsed << endl;
- cout << setw(w) << "std" << setprecision(3) << setw(w) << dev_mean.second.std_elapsed << setw(w) << dev_mean.first.std_elapsed << setw(w) << result_min.std_elapsed << setw(w) << result_max.std_elapsed << endl;
- cout << setw(w) << "tbb" << setprecision(3) << setw(w) << dev_mean.second.tbb_elapsed << setw(w) << dev_mean.first.tbb_elapsed << setw(w) << result_min.tbb_elapsed << setw(w) << result_max.tbb_elapsed << endl;
- cout << endl;
+ pair<PoolResult, PoolResult> dev_mean = standard_deviation_mean(results);
+ size_t w = 10;
+ cout << setw(w) << "scheme" << setw(w) << "mean" << setw(w) << "std-dev" << setw(w) << "min" << setw(w) << "max" << endl;
+ cout << setw(w) << "fast" << setprecision(3) << setw(w) << dev_mean.second.fast_pool_elapsed << setw(w) << dev_mean.first.fast_pool_elapsed << setw(w) << result_min.fast_pool_elapsed << setw(w) << result_max.fast_pool_elapsed << endl;
+ cout << setw(w) << "pool" << setprecision(3) << setw(w) << dev_mean.second.pool_elapsed << setw(w) << dev_mean.first.pool_elapsed << setw(w) << result_min.pool_elapsed << setw(w) << result_max.pool_elapsed << endl;
+ cout << setw(w) << "std" << setprecision(3) << setw(w) << dev_mean.second.std_elapsed << setw(w) << dev_mean.first.std_elapsed << setw(w) << result_min.std_elapsed << setw(w) << result_max.std_elapsed << endl;
+ cout << setw(w) << "tbb" << setprecision(3) << setw(w) << dev_mean.second.tbb_elapsed << setw(w) << dev_mean.first.tbb_elapsed << setw(w) << result_min.tbb_elapsed << setw(w) << result_max.tbb_elapsed << endl;
+ cout << endl;
 }
 
 void print(PoolResults const &results)
 {
- size_t w = 10;
- cout << setw(4) << "len" << setw(w) << "fast/m" << setw(w) << "pool/m" << setw(w) << "std/m" << setw(w) << "tbb/m" << endl;//setw(w) << "tbb/l" << endl;
- cout << setw(0) << "--------------------------------------------" << endl;
- std::vector<PoolResult> results_vec;
- BOOST_FOREACH(PoolResults::value_type const &iter, results)
- {
- PoolResult const &result = iter.second;
- cout << setw(4) << iter.first << setprecision(3) << setw(w);
- if (result.mono_elapsed == 0)
- {
- cout << setw(w) << "mono = 0s" << endl;
- continue;
- }
- PoolResult ratio = result*(1./result.mono_elapsed);
- ratio.mono_elapsed = 1;
-
- if (first_result)
- {
- result_min = result_max = ratio;
- first_result = false;
- }
- else
- {
- result_min.update_min(ratio);
- result_max.update_max(ratio);
- }
- cout << ratio.fast_pool_elapsed << setw(w) << ratio.pool_elapsed << setw(w) << ratio.std_elapsed << setw(w) << ratio.tbb_elapsed << endl;//setw(w) << result.tbb_elapsed/result.local_mono_elapsed << endl;
- results_vec.push_back(ratio);
- cumulative.push_back(ratio);
- }
- cout << endl;
- print_cumulative(results_vec);
- cout << endl << endl;
+ size_t w = 10;
+ cout << setw(4) << "len" << setw(w) << "fast/m" << setw(w) << "pool/m" << setw(w) << "std/m" << setw(w) << "tbb/m" << endl;//setw(w) << "tbb/l" << endl;
+ cout << setw(0) << "--------------------------------------------" << endl;
+ std::vector<PoolResult> results_vec;
+ BOOST_FOREACH(PoolResults::value_type const &iter, results)
+ {
+ PoolResult const &result = iter.second;
+ cout << setw(4) << iter.first << setprecision(3) << setw(w);
+ if (result.mono_elapsed == 0)
+ {
+ cout << setw(w) << "mono = 0s" << endl;
+ continue;
+ }
+ PoolResult ratio = result*(1./result.mono_elapsed);
+ ratio.mono_elapsed = 1;
+
+ if (first_result)
+ {
+ result_min = result_max = ratio;
+ first_result = false;
+ }
+ else
+ {
+ result_min.update_min(ratio);
+ result_max.update_max(ratio);
+ }
+ cout << ratio.fast_pool_elapsed << setw(w) << ratio.pool_elapsed << setw(w) << ratio.std_elapsed << setw(w) << ratio.tbb_elapsed << endl;//setw(w) << result.tbb_elapsed/result.local_mono_elapsed << endl;
+ results_vec.push_back(ratio);
+ cumulative.push_back(ratio);
+ }
+ cout << endl;
+ print_cumulative(results_vec);
+ cout << endl << endl;
 }
 
 void heading(const char *text, char star = '-')
 {
- size_t len = 55;
- for (size_t n = 0; n < len; ++n)
- cout << star;
- cout << endl << "\t\t" << text << endl;
- for (size_t n = 0; n < len; ++n)
- cout << star;
- cout << endl;
+ size_t len = 55;
+ for (size_t n = 0; n < len; ++n)
+ cout << star;
+ cout << endl << "\t\t" << text << endl;
+ for (size_t n = 0; n < len; ++n)
+ cout << star;
+ cout << endl;
 }
 
 #ifdef WIN32
@@ -273,87 +273,87 @@
 
 void test_pools()
 {
- size_t length = 1;
+ size_t length = 1;
 
- {
- boost::pool<> storage(sizeof(int));
- for (size_t n = 0; n < length; ++n)
- {
- int *p = reinterpret_cast<int *>(storage.malloc());
- }
- }
- {
- boost::object_pool<int> storage;
- for (size_t n = 0; n < length; ++n)
- {
- int *p = storage.malloc();
- }
- }
-
- if (0)
- {
- boost::object_pool<string> storage;
- for (size_t n = 0; n < length; ++n)
- {
- string *p = storage.malloc();
- }
- // crashes when storage is released?
- }
-
- {
- length = 4;
- // storage starts on the stack (in this case, 10k of it), then merges into the heap as needed
- monotonic::storage<10*1024> storage;
- for (size_t n = 0; n < length; ++n)
- {
- // create a new int from storage
- int &n0 = storage.create<int>();
-
- // create a new string (uses correct alignment)
- string const &s1 = storage.create<string>("foo");
- BOOST_ASSERT(s1 == "foo");
-
- // allocate 37 bytes with alignment 1
- char *array0 = storage.allocate_bytes(37);
- fill_n(array0, 37, 42);
-
- // allocate 2537 bytes with 64-byte alignment
- char *array1 = storage.allocate_bytes(2537, 64);
- fill_n(array1, 2537, 123);
-
- // allocate 1283 bytes with machine alignment
- char *array2 = storage.allocate_bytes<1283>();
- fill_n(array2, 1283, 42);
-
- array<Unaligned, 42> &array3 = storage.create<array<Unaligned, 42> >();
-
- // destroy objects. this only calls the destructors; it does not release memory
- storage.destroy(s1);
-
- cout << "storage.fixed, heap, total used: " << storage.fixed_used() << ", " << storage.heap_used() << ", " << storage.used() << endl;
- }
- // storage is released. if this was only ever on the stack, no work is done
- }
+ {
+ boost::pool<> storage(sizeof(int));
+ for (size_t n = 0; n < length; ++n)
+ {
+ int *p = reinterpret_cast<int *>(storage.malloc());
+ }
+ }
+ {
+ boost::object_pool<int> storage;
+ for (size_t n = 0; n < length; ++n)
+ {
+ int *p = storage.malloc();
+ }
+ }
+
+ if (0)
+ {
+ boost::object_pool<string> storage;
+ for (size_t n = 0; n < length; ++n)
+ {
+ string *p = storage.malloc();
+ }
+ // crashes when storage is released?
+ }
+
+ {
+ length = 4;
+ // storage starts on the stack (in this case, 10k of it), then merges into the heap as needed
+ monotonic::storage<10*1024> storage;
+ for (size_t n = 0; n < length; ++n)
+ {
+ // create a new int from storage
+ int &n0 = storage.create<int>();
+
+ // create a new string (uses correct alignment)
+ string const &s1 = storage.create<string>("foo");
+ BOOST_ASSERT(s1 == "foo");
+
+ // allocate 37 bytes with alignment 1
+ char *array0 = storage.allocate_bytes(37);
+ fill_n(array0, 37, 42);
+
+ // allocate 2537 bytes with 64-byte alignment
+ char *array1 = storage.allocate_bytes(2537, 64);
+ fill_n(array1, 2537, 123);
+
+ // allocate 1283 bytes with machine alignment
+ char *array2 = storage.allocate_bytes<1283>();
+ fill_n(array2, 1283, 42);
+
+ array<Unaligned, 42> &array3 = storage.create<array<Unaligned, 42> >();
+
+ // destroy objects. this only calls the destructors; it does not release memory
+ storage.destroy(s1);
+
+ cout << "storage.fixed, heap, total used: " << storage.fixed_used() << ", " << storage.heap_used() << ", " << storage.used() << endl;
+ }
+ // storage is released. if this was only ever on the stack, no work is done
+ }
 }
 
 template <class Storage>
 void test_locals(Storage &storage, size_t count)
 {
- if (count == 0)
- return;
- typedef typename Storage::template allocator<int>::type allocator;
- typedef typename Storage::template allocator<char>::type char_allocator;
- std::list<int, allocator > list;
- fill_n(back_inserter(list), 100, 42);
- typedef std::basic_string<char, std::char_traits<char>, char_allocator> String;
+ if (count == 0)
+ return;
+ typedef typename Storage::template allocator<int>::type allocator;
+ typedef typename Storage::template allocator<char>::type char_allocator;
+ std::list<int, allocator > list;
+ fill_n(back_inserter(list), 100, 42);
+ typedef std::basic_string<char, std::char_traits<char>, char_allocator> String;
 /*
- String &s = storage.create<String>("foo");
- for (size_t n = 0; n < 100; ++n)
- s += "bar";
- std::vector<int, allocator > vec;
- vec.resize(1000);
- storage.destroy(s);
- test_locals(storage, --count);
+ String &s = storage.create<String>("foo");
+ for (size_t n = 0; n < 100; ++n)
+ s += "bar";
+ std::vector<int, allocator > vec;
+ vec.resize(1000);
+ storage.destroy(s);
+ test_locals(storage, --count);
 */
 }
 
@@ -362,188 +362,188 @@
 
 void test_locals_mono()
 {
- monotonic::local<local_1> storage1;
- //monotonic::local<local_2> storage2;
- for (size_t n = 0; n < 10; ++n)
- {
- //test_locals(storage1, 4);
- //test_locals(storage2, 2);
- }
- //cout << "test_locals: storage1 stack,heap =" << storage1.fixed_used() << ", " << storage1.heap_used() << endl;
- //cout << "test_locals: storage2 stack,heap =" << storage2.fixed_used() << ", " << storage2.heap_used() << endl;
+ monotonic::local<local_1> storage1;
+ //monotonic::local<local_2> storage2;
+ for (size_t n = 0; n < 10; ++n)
+ {
+ //test_locals(storage1, 4);
+ //test_locals(storage2, 2);
+ }
+ //cout << "test_locals: storage1 stack,heap =" << storage1.fixed_used() << ", " << storage1.heap_used() << endl;
+ //cout << "test_locals: storage2 stack,heap =" << storage2.fixed_used() << ", " << storage2.heap_used() << endl;
 }
 
 
 void test_locals_std_impl(size_t count)
 {
- if (count == 0)
- return;
- std::list<int> list;
- fill_n(back_inserter(list), 100, 42);
- string s = "foo";
- for (size_t n = 0; n < 100; ++n)
- s += "bar";
- std::vector<int> vec;
- vec.resize(1000);
- test_locals_std_impl(--count);
+ if (count == 0)
+ return;
+ std::list<int> list;
+ fill_n(back_inserter(list), 100, 42);
+ string s = "foo";
+ for (size_t n = 0; n < 100; ++n)
+ s += "bar";
+ std::vector<int> vec;
+ vec.resize(1000);
+ test_locals_std_impl(--count);
 }
 
 void test_locals_std()
 {
- for (size_t n = 0; n < 10; ++n)
- {
- test_locals_std_impl(4);
- }
+ for (size_t n = 0; n < 10; ++n)
+ {
+ test_locals_std_impl(4);
+ }
 }
 
 void test_locals(size_t count)
 {
- boost::timer t0;
- for (size_t n = 0; n < count; ++n)
- {
- test_locals_mono();
- }
- double mono_elapsed = t0.elapsed();
-
- boost::timer t1;
- for (size_t n = 0; n < count; ++n)
- {
- test_locals_std();
- }
- double std_elapsed = t1.elapsed();
+ boost::timer t0;
+ for (size_t n = 0; n < count; ++n)
+ {
+ test_locals_mono();
+ }
+ double mono_elapsed = t0.elapsed();
+
+ boost::timer t1;
+ for (size_t n = 0; n < count; ++n)
+ {
+ test_locals_std();
+ }
+ double std_elapsed = t1.elapsed();
 
- cout << "mono: " << mono_elapsed << endl;
- cout << "std : " << std_elapsed << endl;
+ cout << "mono: " << mono_elapsed << endl;
+ cout << "std : " << std_elapsed << endl;
 }
 
 
 int main()
 {
- try
- {
- cout << "results of running test at:" << endl;
- cout << "https://svn.boost.org/svn/boost/sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp" << endl << endl;
-
- //test_locals(10000);
- //test_pools();
- //return 0;
-
- boost::timer timer;
- Type test_map_vector_types;
- Type test_dupe_list_types;
-
- bool run_small = 1;//true;
- bool run_medium = 1;//true;
- bool run_large = 1;//true;
-
- // test for Luke
- //Type types = Type::None;
- //types.Include(Type::TBB);
- //types.Include(Type::Monotonic);
- //print(run_tests(2, 10000, 2, "test_map_erase<int>", test_map_erase(), types));
- //return 0;
-
- // small-size (~100 elements) containers
- if (run_small)
- {
- heading("SMALL");
- #ifndef WIN32
- print(run_tests(100000, 100, 10, "string_cat", test_string_cat()));
- print(run_tests(100000, 100, 10, "list_string", test_list_string()));
- print(run_tests(75000, 100, 10, "list_create<int>", test_list_create<int>()));
- print(run_tests(75000, 100, 10, "list_sort<int>", test_list_sort<int>()));
- print(run_tests(2000000, 100, 10, "vector_create<int>", test_vector_create()));
- print(run_tests(200000, 100, 10, "vector_sort<int>", test_vector_sort<int>()));
- print(run_tests(1000000, 100, 10, "vector_dupe", test_vector_dupe()));
- print(run_tests(50000, 100, 10, "list_dupe", test_list_dupe()));
- print(run_tests(500000, 100, 10, "vector_accumulate", test_vector_accumulate()));
- print(run_tests(10000, 100, 10, "set_vector", test_set_vector()));
- print(run_tests(2000, 100, 10, "map_vector<int>", test_map_vector<int>()));
- #else
- print(run_tests(50000, 100, 10, "string_cat", test_string_cat()));
- print(run_tests(50000, 100, 10, "list_string", test_list_string()));
- print(run_tests(50000, 100, 10, "list_create<int>", test_list_create<int>()));
- print(run_tests(5000, 100, 10, "list_sort<int>", test_list_sort<int>()));
- print(run_tests(2000000, 100, 10, "vector_create<int>", test_vector_create()));
- print(run_tests(20000, 100, 10, "vector_sort<int>", test_vector_sort<int>()));
- print(run_tests(100000, 100, 10, "vector_dupe", test_vector_dupe()));
- print(run_tests(20000, 100, 10, "list_dupe", test_list_dupe()));
- print(run_tests(500000, 100, 10, "vector_accumulate", test_vector_accumulate()));
- print(run_tests(50, 100, 10, "set_vector", test_set_vector()));
- print(run_tests(500, 100, 10, "map_vector<int>", test_map_vector<int>()));
- #endif
-
- heading("SUMMARY", '*');
- print_cumulative(cumulative);
- }
-
- // medium-size (~1000 elements) containers
- if (run_medium)
- {
- heading("MEDIUM");
- print(run_tests(10000, 1000, 10, "list_create<int>", test_list_create<int>()));
- print(run_tests(5000, 1000, 10, "list_sort<int>", test_list_sort<int>()));
-
- #ifndef WIN32
- print(run_tests(1000000, 100000, 10, "vector_create<int>", test_vector_create()));
- print(run_tests(300, 10000, 10, "vector_sort<int>", test_vector_sort<int>()));
- print(run_tests(1000000, 10000, 10, "vector_dupe", test_vector_dupe()));
- print(run_tests(2000, 1000, 10, "list_dupe", test_list_dupe()));
- print(run_tests(5000000, 2000, 10, "vector_accumulate", test_vector_accumulate()));
- print(run_tests(500, 1000, 10, "set_vector", test_set_vector()));
- print(run_tests(500, 1000, 10, "map_vector<int>", test_map_vector<int>()));
- #else
- print(run_tests(1000, 100000, 10, "vector_create<int>", test_vector_create()));
- print(run_tests(30000, 1000, 10, "vector_sort<int>", test_vector_sort<int>()));
- print(run_tests(5000, 10000, 10, "vector_dupe", test_vector_dupe()));
- print(run_tests(500, 1000, 10, "list_dupe", test_list_dupe(), test_dupe_list_types));
- print(run_tests(50000, 2000, 10, "vector_accumulate", test_vector_accumulate()));
- print(run_tests(20, 500, 5, "set_vector", test_set_vector()));
- print(run_tests(50, 1000, 10, "map_vector<int>", test_map_vector<int>()));
- #endif
- heading("SUMMARY", '*');
- print_cumulative(cumulative);
- }
-
- // large-size (~1000000 elements) containers
- if (run_large)
- {
- heading("LARGE");
- #ifndef WIN32
- print(run_tests(100, 25000, 10, "list_create<int>", test_list_create<int>()));
- print(run_tests(10, 100000, 10, "list_sort<int>", test_list_sort<int>()));
- print(run_tests(1000000, 10000000, 10, "vector_create<int>", test_vector_create()));
- print(run_tests(100, 500000, 10, "vector_sort<int>", test_vector_sort<int>()));
-
- print(run_tests(1000000, 100000000, 10, "vector_dupe", test_vector_dupe()));
- print(run_tests(100, 10000, 10, "list_dupe", test_list_dupe()));
- print(run_tests(1000000, 20000000, 10, "vector_accumulate", test_vector_accumulate()));
- print(run_tests(10, 50000, 10, "set_vector", test_set_vector()));
- print(run_tests(10, 10000, 10, "map_vector<int>", test_map_vector<int>()));
- #else
- print(run_tests(10, 25000, 10, "list_create<int>", test_list_create<int>()));
- print(run_tests(10, 100000, 10, "list_sort<int>", test_list_sort<int>()));
- print(run_tests(1000, 1000000, 10, "vector_create<int>", test_vector_create()));
- print(run_tests(300, 500000, 10, "vector_sort<int>", test_vector_sort<int>()));
- print(run_tests(200, 10000000, 10, "vector_dupe", test_vector_dupe()));
- print(run_tests(50, 10000, 10, "list_dupe", test_list_dupe(), test_dupe_list_types));
- print(run_tests(500, 10000000, 10, "vector_accumulate", test_vector_accumulate()));
- print(run_tests(5, 2000, 5, "set_vector", test_set_vector()));
- print(run_tests(10, 2000, 10, "map_vector<int>", test_map_vector<int>()));
- #endif
- }
-
- heading("FINAL SUMMARY", '*');
- print_cumulative(cumulative);
- cout << endl << "took " << setprecision(3) << timer.elapsed()/60. << " minutes" << endl;
- }
- catch (std::exception &e)
- {
- cout << "exception: " << e.what() << endl;
- return 1;
- }
+ try
+ {
+ cout << "results of running test at:" << endl;
+ cout << "https://svn.boost.org/svn/boost/sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp" << endl << endl;
+
+ //test_locals(10000);
+ //test_pools();
+ //return 0;
+
+ boost::timer timer;
+ Type test_map_vector_types;
+ Type test_dupe_list_types;
+
+ bool run_small = 1;//true;
+ bool run_medium = 1;//true;
+ bool run_large = 1;//true;
+
+ // test for Luke
+ //Type types = Type::None;
+ //types.Include(Type::TBB);
+ //types.Include(Type::Monotonic);
+ //print(run_tests(2, 10000, 2, "test_map_erase<int>", test_map_erase(), types));
+ //return 0;
+
+ // small-size (~100 elements) containers
+ if (run_small)
+ {
+ heading("SMALL");
+ #ifndef WIN32
+ print(run_tests(100000, 100, 10, "string_cat", test_string_cat()));
+ print(run_tests(100000, 100, 10, "list_string", test_list_string()));
+ print(run_tests(75000, 100, 10, "list_create<int>", test_list_create<int>()));
+ print(run_tests(75000, 100, 10, "list_sort<int>", test_list_sort<int>()));
+ print(run_tests(2000000, 100, 10, "vector_create<int>", test_vector_create()));
+ print(run_tests(200000, 100, 10, "vector_sort<int>", test_vector_sort<int>()));
+ print(run_tests(1000000, 100, 10, "vector_dupe", test_vector_dupe()));
+ print(run_tests(50000, 100, 10, "list_dupe", test_list_dupe()));
+ print(run_tests(500000, 100, 10, "vector_accumulate", test_vector_accumulate()));
+ print(run_tests(10000, 100, 10, "set_vector", test_set_vector()));
+ print(run_tests(2000, 100, 10, "map_vector<int>", test_map_vector<int>()));
+ #else
+ print(run_tests(50000, 100, 10, "string_cat", test_string_cat()));
+ print(run_tests(50000, 100, 10, "list_string", test_list_string()));
+ print(run_tests(50000, 100, 10, "list_create<int>", test_list_create<int>()));
+ print(run_tests(5000, 100, 10, "list_sort<int>", test_list_sort<int>()));
+ print(run_tests(2000000, 100, 10, "vector_create<int>", test_vector_create()));
+ print(run_tests(20000, 100, 10, "vector_sort<int>", test_vector_sort<int>()));
+ print(run_tests(100000, 100, 10, "vector_dupe", test_vector_dupe()));
+ print(run_tests(20000, 100, 10, "list_dupe", test_list_dupe()));
+ print(run_tests(500000, 100, 10, "vector_accumulate", test_vector_accumulate()));
+ print(run_tests(50, 100, 10, "set_vector", test_set_vector()));
+ print(run_tests(500, 100, 10, "map_vector<int>", test_map_vector<int>()));
+ #endif
+
+ heading("SUMMARY", '*');
+ print_cumulative(cumulative);
+ }
+
+ // medium-size (~1000 elements) containers
+ if (run_medium)
+ {
+ heading("MEDIUM");
+ print(run_tests(10000, 1000, 10, "list_create<int>", test_list_create<int>()));
+ print(run_tests(5000, 1000, 10, "list_sort<int>", test_list_sort<int>()));
+
+ #ifndef WIN32
+ print(run_tests(1000000, 100000, 10, "vector_create<int>", test_vector_create()));
+ print(run_tests(300, 10000, 10, "vector_sort<int>", test_vector_sort<int>()));
+ print(run_tests(1000000, 10000, 10, "vector_dupe", test_vector_dupe()));
+ print(run_tests(2000, 1000, 10, "list_dupe", test_list_dupe()));
+ print(run_tests(5000000, 2000, 10, "vector_accumulate", test_vector_accumulate()));
+ print(run_tests(500, 1000, 10, "set_vector", test_set_vector()));
+ print(run_tests(500, 1000, 10, "map_vector<int>", test_map_vector<int>()));
+ #else
+ print(run_tests(1000, 100000, 10, "vector_create<int>", test_vector_create()));
+ print(run_tests(30000, 1000, 10, "vector_sort<int>", test_vector_sort<int>()));
+ print(run_tests(5000, 10000, 10, "vector_dupe", test_vector_dupe()));
+ print(run_tests(500, 1000, 10, "list_dupe", test_list_dupe(), test_dupe_list_types));
+ print(run_tests(50000, 2000, 10, "vector_accumulate", test_vector_accumulate()));
+ print(run_tests(20, 500, 5, "set_vector", test_set_vector()));
+ print(run_tests(50, 1000, 10, "map_vector<int>", test_map_vector<int>()));
+ #endif
+ heading("SUMMARY", '*');
+ print_cumulative(cumulative);
+ }
+
+ // large-size (~1000000 elements) containers
+ if (run_large)
+ {
+ heading("LARGE");
+ #ifndef WIN32
+ print(run_tests(100, 25000, 10, "list_create<int>", test_list_create<int>()));
+ print(run_tests(10, 100000, 10, "list_sort<int>", test_list_sort<int>()));
+ print(run_tests(1000000, 10000000, 10, "vector_create<int>", test_vector_create()));
+ print(run_tests(100, 500000, 10, "vector_sort<int>", test_vector_sort<int>()));
+
+ print(run_tests(1000000, 100000000, 10, "vector_dupe", test_vector_dupe()));
+ print(run_tests(100, 10000, 10, "list_dupe", test_list_dupe()));
+ print(run_tests(1000000, 20000000, 10, "vector_accumulate", test_vector_accumulate()));
+ print(run_tests(10, 50000, 10, "set_vector", test_set_vector()));
+ print(run_tests(10, 10000, 10, "map_vector<int>", test_map_vector<int>()));
+ #else
+ print(run_tests(10, 25000, 10, "list_create<int>", test_list_create<int>()));
+ print(run_tests(10, 100000, 10, "list_sort<int>", test_list_sort<int>()));
+ print(run_tests(1000, 1000000, 10, "vector_create<int>", test_vector_create()));
+ print(run_tests(300, 500000, 10, "vector_sort<int>", test_vector_sort<int>()));
+ print(run_tests(200, 10000000, 10, "vector_dupe", test_vector_dupe()));
+ print(run_tests(50, 10000, 10, "list_dupe", test_list_dupe(), test_dupe_list_types));
+ print(run_tests(500, 10000000, 10, "vector_accumulate", test_vector_accumulate()));
+ print(run_tests(5, 2000, 5, "set_vector", test_set_vector()));
+ print(run_tests(10, 2000, 10, "map_vector<int>", test_map_vector<int>()));
+ #endif
+ }
+
+ heading("FINAL SUMMARY", '*');
+ print_cumulative(cumulative);
+ cout << endl << "took " << setprecision(3) << timer.elapsed()/60. << " minutes" << endl;
+ }
+ catch (std::exception &e)
+ {
+ cout << "exception: " << e.what() << endl;
+ return 1;
+ }
 
- return 0;
+ return 0;
 }
 
 //EOF

Modified: sandbox/monotonic/libs/monotonic/test/monotonic.sln
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/monotonic.sln (original)
+++ sandbox/monotonic/libs/monotonic/test/monotonic.sln 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -17,7 +17,6 @@
         EndGlobalSection
         GlobalSection(ProjectConfigurationPlatforms) = postSolution
                 {5688980A-015B-4C7D-8D8D-F5894205FACE}.Debug|Win32.ActiveCfg = Debug|Win32
- {5688980A-015B-4C7D-8D8D-F5894205FACE}.Debug|Win32.Build.0 = Debug|Win32
                 {5688980A-015B-4C7D-8D8D-F5894205FACE}.Release|Win32.ActiveCfg = Release|Win32
                 {5688980A-015B-4C7D-8D8D-F5894205FACE}.Release|Win32.Build.0 = Release|Win32
                 {5688980A-015B-4C7D-8D8D-F5894205FACE}.ReleaseSym|Win32.ActiveCfg = ReleaseSym|Win32
@@ -27,12 +26,10 @@
                 {D4779B0F-266B-46D3-8BCF-0E14EF8B817B}.ReleaseSym|Win32.ActiveCfg = ReleaseSym|Win32
                 {D4779B0F-266B-46D3-8BCF-0E14EF8B817B}.ReleaseSym|Win32.Build.0 = ReleaseSym|Win32
                 {E557E90C-C695-4A7B-B5A6-2F133AF88563}.Debug|Win32.ActiveCfg = Debug|Win32
- {E557E90C-C695-4A7B-B5A6-2F133AF88563}.Debug|Win32.Build.0 = Debug|Win32
                 {E557E90C-C695-4A7B-B5A6-2F133AF88563}.Release|Win32.ActiveCfg = Release|Win32
                 {E557E90C-C695-4A7B-B5A6-2F133AF88563}.Release|Win32.Build.0 = Release|Win32
                 {E557E90C-C695-4A7B-B5A6-2F133AF88563}.ReleaseSym|Win32.ActiveCfg = ReleaseSym|Win32
                 {5FF650E3-53E2-447F-8D2D-A85B76B214D3}.Debug|Win32.ActiveCfg = Debug|Win32
- {5FF650E3-53E2-447F-8D2D-A85B76B214D3}.Debug|Win32.Build.0 = Debug|Win32
                 {5FF650E3-53E2-447F-8D2D-A85B76B214D3}.Release|Win32.ActiveCfg = Release|Win32
                 {5FF650E3-53E2-447F-8D2D-A85B76B214D3}.Release|Win32.Build.0 = Release|Win32
                 {5FF650E3-53E2-447F-8D2D-A85B76B214D3}.ReleaseSym|Win32.ActiveCfg = ReleaseSym|Win32

Modified: sandbox/monotonic/libs/monotonic/test/results/gcc.txt
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/results/gcc.txt (original)
+++ sandbox/monotonic/libs/monotonic/test/results/gcc.txt 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -4,7 +4,7 @@
 https://svn.boost.org/svn/boost/sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp
 
 -------------------------------------------------------
- SMALL
+ SMALL
 -------------------------------------------------------
 list_create<int>: reps=75000, len=100, steps=10..........
 took 9.83s
@@ -214,7 +214,7 @@
 
 
 *******************************************************
- SUMMARY
+ SUMMARY
 *******************************************************
     scheme mean std-dev min max
       fast 21.2 73 0.474 452
@@ -223,7 +223,7 @@
        tbb 1.56 0.872 0.333 4.67
 
 -------------------------------------------------------
- MEDIUM
+ MEDIUM
 -------------------------------------------------------
 list_create<int>: reps=10000, len=1000, steps=10..........
 took 30.2s
@@ -433,7 +433,7 @@
 
 
 *******************************************************
- SUMMARY
+ SUMMARY
 *******************************************************
     scheme mean std-dev min max
       fast 47.6 208 0.25 1.63e+03
@@ -442,7 +442,7 @@
        tbb 1.55 0.824 0.333 4.67
 
 -------------------------------------------------------
- LARGE
+ LARGE
 -------------------------------------------------------
 list_create<int>: reps=100, len=25000, steps=10..........
 took 160s
@@ -652,7 +652,7 @@
 
 
 *******************************************************
- FINAL SUMMARY
+ FINAL SUMMARY
 *******************************************************
     scheme mean std-dev min max
       fast 36.3 173 0.25 1.63e+03

Modified: sandbox/monotonic/libs/monotonic/test/results/msvc.txt
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/results/msvc.txt (original)
+++ sandbox/monotonic/libs/monotonic/test/results/msvc.txt 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -2,7 +2,7 @@
 https://svn.boost.org/svn/boost/sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp
 
 -------------------------------------------------------
- SMALL
+ SMALL
 -------------------------------------------------------
 list_create<int>: reps=50000, len=100, steps=10..........
 took 12.148s
@@ -212,7 +212,7 @@
 
 
 *******************************************************
- SUMMARY
+ SUMMARY
 *******************************************************
     scheme mean std-dev min max
       fast 57.9 199 0.603 1.32e+003
@@ -221,7 +221,7 @@
        tbb 1.44 0.45 0.5 4
 
 -------------------------------------------------------
- MEDIUM
+ MEDIUM
 -------------------------------------------------------
 list_create<int>: reps=10000, len=1000, steps=10..........
 took 52.1s
@@ -426,7 +426,7 @@
 
 
 *******************************************************
- SUMMARY
+ SUMMARY
 *******************************************************
     scheme mean std-dev min max
       fast 43.9 156 0.603 1.32e+003
@@ -435,7 +435,7 @@
        tbb 1.35 0.465 0.5 4
 
 -------------------------------------------------------
- LARGE
+ LARGE
 -------------------------------------------------------
 list_create<int>: reps=10, len=25000, steps=10..........
 took 21.3s
@@ -640,7 +640,7 @@
 
 
 *******************************************************
- FINAL SUMMARY
+ FINAL SUMMARY
 *******************************************************
     scheme mean std-dev min max
       fast 35.4 132 0.603 1.32e+003

Modified: sandbox/monotonic/libs/object_model/src/generic/object.cpp
==============================================================================
--- sandbox/monotonic/libs/object_model/src/generic/object.cpp (original)
+++ sandbox/monotonic/libs/object_model/src/generic/object.cpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -16,100 +16,100 @@
 
 namespace generic
 {
- // object_base
+ // object_base
 
- object_base::object_base()
- : reg(0), type(0), number(0)
- {
- }
-
- object_base::object_base(const object_base &other)
- : reg(other.reg), type(other.type), number(other.number)
- {
- }
-
- void object_base::construct(registry &r, klass const &k, handle h)
- {
- reg = &r;
- type = &k;
- number = h;
- }
-
- registry &object_base::get_registry() const
- {
- if (reg == 0)
- throw empty_object();
- return *reg;
- }
- klass const &object_base::get_class() const
- {
- if (type == 0)
- throw empty_object();
- return *type;
- }
-
- type::number object_base::get_type_number() const
- {
- return get_class().get_type_number();
- }
-
- handle object_base::get_handle() const
- {
- return number;
- }
-
- bool object_base::exists() const
- {
- return get_registry().exists(number);
- }
-
- const object_base &object_base::get_storage() const
- {
- return get_registry().get_storage(get_handle());
- }
-
- object_base &object_base::get_storage()
- {
- return get_registry().get_storage(get_handle());
- }
-
-
- object_base &mutable_object::get_storage()
- {
- return get_registry().get_storage(get_handle());
- }
-
- // object
-
- object::object() : konst(false) { }
-
- object::object(const const_object& obj) : const_object(obj), konst(true) { }
-
- object::object(const mutable_object& obj) : const_object(obj), konst(false) { }
-
- object &object::operator=(const const_object& obj)
- {
- const_object::operator=(obj);
- konst = true;
- return *this;
- }
-
- object &object::operator=(const mutable_object& obj)
- {
- const_object::operator=(obj);
- konst = false;
- return *this;
- }
- object_base &object::get_storage()
- {
- if (is_const())
- throw const_error();
- return get_registry().get_storage(get_handle());
- }
- const object_base &object::get_storage() const
- {
- return get_registry().get_storage(get_handle());
- }
+ object_base::object_base()
+ : reg(0), type(0), number(0)
+ {
+ }
+
+ object_base::object_base(const object_base &other)
+ : reg(other.reg), type(other.type), number(other.number)
+ {
+ }
+
+ void object_base::construct(registry &r, klass const &k, handle h)
+ {
+ reg = &r;
+ type = &k;
+ number = h;
+ }
+
+ registry &object_base::get_registry() const
+ {
+ if (reg == 0)
+ throw empty_object();
+ return *reg;
+ }
+ klass const &object_base::get_class() const
+ {
+ if (type == 0)
+ throw empty_object();
+ return *type;
+ }
+
+ type::number object_base::get_type_number() const
+ {
+ return get_class().get_type_number();
+ }
+
+ handle object_base::get_handle() const
+ {
+ return number;
+ }
+
+ bool object_base::exists() const
+ {
+ return get_registry().exists(number);
+ }
+
+ const object_base &object_base::get_storage() const
+ {
+ return get_registry().get_storage(get_handle());
+ }
+
+ object_base &object_base::get_storage()
+ {
+ return get_registry().get_storage(get_handle());
+ }
+
+
+ object_base &mutable_object::get_storage()
+ {
+ return get_registry().get_storage(get_handle());
+ }
+
+ // object
+
+ object::object() : konst(false) { }
+
+ object::object(const const_object& obj) : const_object(obj), konst(true) { }
+
+ object::object(const mutable_object& obj) : const_object(obj), konst(false) { }
+
+ object &object::operator=(const const_object& obj)
+ {
+ const_object::operator=(obj);
+ konst = true;
+ return *this;
+ }
+
+ object &object::operator=(const mutable_object& obj)
+ {
+ const_object::operator=(obj);
+ konst = false;
+ return *this;
+ }
+ object_base &object::get_storage()
+ {
+ if (is_const())
+ throw const_error();
+ return get_registry().get_storage(get_handle());
+ }
+ const object_base &object::get_storage() const
+ {
+ return get_registry().get_storage(get_handle());
+ }
 }
 
 const generic::object null_object;

Modified: sandbox/monotonic/libs/object_model/test/basic_tests.cpp
==============================================================================
--- sandbox/monotonic/libs/object_model/test/basic_tests.cpp (original)
+++ sandbox/monotonic/libs/object_model/test/basic_tests.cpp 2009-07-07 19:06:20 EDT (Tue, 07 Jul 2009)
@@ -32,30 +32,30 @@
 
 BOOST_AUTO_TEST_CASE(test_any)
 {
- om::registry<> reg;
- reg.add_builtins();
- om::object<> obj = reg.create<int>(42);
- BOOST_ASSERT(obj.is_type<int>());
- BOOST_ASSERT(reg.deref<int>(obj) == 42);
+ om::registry<> reg;
+ reg.add_builtins();
+ om::object<> obj = reg.create<int>(42);
+ BOOST_ASSERT(obj.is_type<int>());
+ BOOST_ASSERT(reg.deref<int>(obj) == 42);
 
- //obj.set("foo", om::null_object);
+ //obj.set("foo", om::null_object);
 }
 
 BOOST_AUTO_TEST_CASE(test_type_mismatch)
 {
- om::registry<> reg;
- reg.add_builtins();
- bool caught = false;
- try
- {
- om::object<> obj = reg.create<float>(42);
- om::object<int> num = obj;
- }
- catch (om::type_mismatch)
- {
- caught = true;
- }
- BOOST_ASSERT(caught);
+ om::registry<> reg;
+ reg.add_builtins();
+ bool caught = false;
+ try
+ {
+ om::object<> obj = reg.create<float>(42);
+ om::object<int> num = obj;
+ }
+ catch (om::type_mismatch)
+ {
+ caught = true;
+ }
+ BOOST_ASSERT(caught);
 }
 
 #include <boost/monotonic/allocator.hpp>
@@ -64,165 +64,165 @@
 
 BOOST_AUTO_TEST_CASE(test_monotonic)
 {
- {
- om::registry<mono_reg> reg;
- reg.add_builtins();
- om::object<int> n = reg.create<int>(42);
- size_t used = monotonic::static_storage<>::used();
- BOOST_ASSERT(used > 0);
- }
- monotonic::static_storage<>::reset();
+ {
+ om::registry<mono_reg> reg;
+ reg.add_builtins();
+ om::object<int> n = reg.create<int>(42);
+ size_t used = monotonic::static_storage<>::used();
+ BOOST_ASSERT(used > 0);
+ }
+ monotonic::static_storage<>::reset();
 }
 
 BOOST_AUTO_TEST_CASE(test_vector)
 {
- om::registry<> reg;
- typedef om::registry<>::vector_type vector;
- reg.register_class<vector>();
- reg.register_class<int>();
- om::object<vector> vec = reg.create<vector>();
- vec->push_back(reg.create<int>(42));
- BOOST_ASSERT(vec.exists());
- BOOST_ASSERT(vec->size() == 1);
+ om::registry<> reg;
+ typedef om::registry<>::vector_type vector;
+ reg.register_class<vector>();
+ reg.register_class<int>();
+ om::object<vector> vec = reg.create<vector>();
+ vec->push_back(reg.create<int>(42));
+ BOOST_ASSERT(vec.exists());
+ BOOST_ASSERT(vec->size() == 1);
 }
 
 BOOST_AUTO_TEST_CASE(test_type_specifier)
 {
- om::registry<> reg;
- reg.register_class<void>();
- reg.register_class<int>();
+ om::registry<> reg;
+ reg.register_class<void>();
+ reg.register_class<int>();
 
-// om::string<> text = om::type::make_specifier<int>().to_string(reg);
+// om::string<> text = om::type::make_specifier<int>().to_string(reg);
 }
 
 BOOST_AUTO_TEST_CASE(test_values)
 {
- om::registry<om::set_label<int> > r;
- r.register_class<int>();
- om::object<int> n = r.create<int>();
- BOOST_ASSERT(n.exists());
- BOOST_ASSERT(n.is_type<int>());
- r.set_value(n, 42);
- BOOST_ASSERT(r.get_value<int>(n) == 42);
+ om::registry<om::set_label<int> > r;
+ r.register_class<int>();
+ om::object<int> n = r.create<int>();
+ BOOST_ASSERT(n.exists());
+ BOOST_ASSERT(n.is_type<int>());
+ r.set_value(n, 42);
+ BOOST_ASSERT(r.get_value<int>(n) == 42);
 }
 
 BOOST_AUTO_TEST_CASE(test_int_labels)
 {
- om::registry<om::set_label<int> > r;
- r.register_class<void>();
- om::object<void> parent = r.create<void>();
- om::object<void> child = r.create<void>();
- r.set_child(parent, 42, child);
- BOOST_ASSERT(r.has_child(parent, 42));
+ om::registry<om::set_label<int> > r;
+ r.register_class<void>();
+ om::object<void> parent = r.create<void>();
+ om::object<void> child = r.create<void>();
+ r.set_child(parent, 42, child);
+ BOOST_ASSERT(r.has_child(parent, 42));
 }
 
 BOOST_AUTO_TEST_CASE(test_string_labels)
 {
- om::registry<> r;
- r.register_class<void>();
- om::object<void> parent = r.create<void>();
- om::object<void> child = r.create<void>();
- r.set_child(parent, "child", child);
- BOOST_ASSERT(r.has_child(parent, "child"));
+ om::registry<> r;
+ r.register_class<void>();
+ om::object<void> parent = r.create<void>();
+ om::object<void> child = r.create<void>();
+ r.set_child(parent, "child", child);
+ BOOST_ASSERT(r.has_child(parent, "child"));
 }
 
 BOOST_AUTO_TEST_CASE(test_type_traits)
 {
- BOOST_STATIC_ASSERT(om::type::traits<int>::type_number == om::type::number::Int);
- BOOST_STATIC_ASSERT(om::type::traits<void>::type_number == om::type::number::Void);
+ BOOST_STATIC_ASSERT(om::type::traits<int>::type_number == om::type::number::Int);
+ BOOST_STATIC_ASSERT(om::type::traits<void>::type_number == om::type::number::Void);
 }
 
 BOOST_AUTO_TEST_CASE(test_generic_object)
 {
- om::registry<> reg;
+ om::registry<> reg;
 
- reg.register_class<void>();
- BOOST_ASSERT(reg.has_class<void>());
+ reg.register_class<void>();
+ BOOST_ASSERT(reg.has_class<void>());
 
- om::generic::object obj = reg.create<void>();
- BOOST_ASSERT(obj.exists());
+ om::generic::object obj = reg.create<void>();
+ BOOST_ASSERT(obj.exists());
 
- om::generic::const_object const_obj = obj;
- BOOST_ASSERT(const_obj.exists());
- om::generic::mutable_object mobj = obj;
+ om::generic::const_object const_obj = obj;
+ BOOST_ASSERT(const_obj.exists());
+ om::generic::mutable_object mobj = obj;
 
- BOOST_ASSERT(reg.num_classes() == 1);
- BOOST_ASSERT(reg.num_instances() == 1);
+ BOOST_ASSERT(reg.num_classes() == 1);
+ BOOST_ASSERT(reg.num_instances() == 1);
 
- BOOST_ASSERT(obj.exists());
- reg.destroy(obj);
- BOOST_ASSERT(!obj.exists());
- BOOST_ASSERT(reg.num_instances() == 0);
+ BOOST_ASSERT(obj.exists());
+ reg.destroy(obj);
+ BOOST_ASSERT(!obj.exists());
+ BOOST_ASSERT(reg.num_instances() == 0);
 }
 
 BOOST_AUTO_TEST_CASE(test_object)
 {
- om::registry<> reg;
- reg.register_class<int>();
- BOOST_ASSERT(reg.has_class<int>());
-
- om::object<int> num = reg.create<int>();
- BOOST_ASSERT(num.exists());
- BOOST_ASSERT(num.is_type<int>());
-
- *num = 42;
-
- BOOST_ASSERT((reg.deref<int>(num) == 42));
+ om::registry<> reg;
+ reg.register_class<int>();
+ BOOST_ASSERT(reg.has_class<int>());
+
+ om::object<int> num = reg.create<int>();
+ BOOST_ASSERT(num.exists());
+ BOOST_ASSERT(num.is_type<int>());
+
+ *num = 42;
+
+ BOOST_ASSERT((reg.deref<int>(num) == 42));
 }
 
 struct Foo
 {
- int num;
- std::string str;
+ int num;
+ std::string str;
 
- void bar()
- {
- }
- int grok()
- {
- return 42;
- }
- int spam(int n)
- {
- return n*2;
- }
+ void bar()
+ {
+ }
+ int grok()
+ {
+ return 42;
+ }
+ int spam(int n)
+ {
+ return n*2;
+ }
 };
 
 BOOST_OBJECT_MODEL_TRAITS_NUM(Foo, 666);
 
 BOOST_AUTO_TEST_CASE(test_builder)
 {
- om::registry<> reg;
- reg.add_builtins();
- typedef om::registry<>::vector_type vector;
-
- om::class_builder<Foo>(reg)
- .methods
- //("bar", &Foo::bar)
- ("spam", &Foo::spam)
- ("grok", &Foo::grok)
- .fields
- ("num", &Foo::num)
- ("str", &Foo::str)
- ;
- om::object<Foo> foo = reg.create<Foo>();
- BOOST_ASSERT(foo.exists());
- BOOST_ASSERT(foo.is_type<Foo>());
- BOOST_ASSERT(reg.has_method(foo, "grok"));
- BOOST_ASSERT(reg.has_method(foo, "spam"));
-
- // invoke foo::grok using a stack
- om::object<vector> stack = reg.create<vector>();
- reg.get_method(foo, "grok").invoke(foo, *stack);
- BOOST_ASSERT(stack->size() == 1);
- BOOST_ASSERT(stack->at(0).is_type<int>());
- BOOST_ASSERT(reg.deref<int>(stack->at(0)) == 42);
-
- // invoke foo::spam using the same stack
- reg.get_method(foo, "spam").invoke(foo, *stack);
- BOOST_ASSERT(stack->size() == 1);
- BOOST_ASSERT(stack->at(0).is_type<int>());
- BOOST_ASSERT(reg.deref<int>(stack->at(0)) == 42*2);
+ om::registry<> reg;
+ reg.add_builtins();
+ typedef om::registry<>::vector_type vector;
+
+ om::class_builder<Foo>(reg)
+ .methods
+ //("bar", &Foo::bar)
+ ("spam", &Foo::spam)
+ ("grok", &Foo::grok)
+ .fields
+ ("num", &Foo::num)
+ ("str", &Foo::str)
+ ;
+ om::object<Foo> foo = reg.create<Foo>();
+ BOOST_ASSERT(foo.exists());
+ BOOST_ASSERT(foo.is_type<Foo>());
+ BOOST_ASSERT(reg.has_method(foo, "grok"));
+ BOOST_ASSERT(reg.has_method(foo, "spam"));
+
+ // invoke foo::grok using a stack
+ om::object<vector> stack = reg.create<vector>();
+ reg.get_method(foo, "grok").invoke(foo, *stack);
+ BOOST_ASSERT(stack->size() == 1);
+ BOOST_ASSERT(stack->at(0).is_type<int>());
+ BOOST_ASSERT(reg.deref<int>(stack->at(0)) == 42);
+
+ // invoke foo::spam using the same stack
+ reg.get_method(foo, "spam").invoke(foo, *stack);
+ BOOST_ASSERT(stack->size() == 1);
+ BOOST_ASSERT(stack->at(0).is_type<int>());
+ BOOST_ASSERT(reg.deref<int>(stack->at(0)) == 42*2);
 }
 
 #include <boost/spirit/core.hpp>
@@ -230,43 +230,43 @@
 
 BOOST_AUTO_TEST_CASE(test_basic_parser)
 {
- return;
+ return;
 
- using namespace boost::spirit;
- chlit<> plus('+');
- chlit<> minus('-');
- chlit<> times('*');
- chlit<> divide('/');
- chlit<> oppar('(');
- chlit<> clpar(')');
- chlit<> opbrace('{');
- chlit<> clbrace('}');
-
- rule<> constant;
- rule<> ident;
- rule<> op;
- rule<> sequence;
- rule<> continuation;
-
- constant = int_p;
- op = plus || minus || times || divide;
- ident = +range_p('a','z');
- sequence = *(constant || op || ident);
- continuation = opbrace >> sequence >> clbrace;
-
- bool p0 = parse("1", constant, space_p).full;
- bool p7 = parse("1 2", constant >> constant, space_p).full;
- bool p4 = parse("+", op, space_p).full;
- bool p5 = parse("+ +", op >> op, space_p).full;
- bool p6 = parse("+ +", *op, space_p).full;
- bool p2 = parse("1 2 +", *constant >> op, space_p).full;
- bool p1 = parse("1 2", *constant, space_p).full;
- bool p3 = parse("a b + 1 2 *", sequence, space_p).full;
-
- BOOST_ASSERT(p0);
- BOOST_ASSERT(p1);
- BOOST_ASSERT(p2);
- BOOST_ASSERT(p3);
+ using namespace boost::spirit;
+ chlit<> plus('+');
+ chlit<> minus('-');
+ chlit<> times('*');
+ chlit<> divide('/');
+ chlit<> oppar('(');
+ chlit<> clpar(')');
+ chlit<> opbrace('{');
+ chlit<> clbrace('}');
+
+ rule<> constant;
+ rule<> ident;
+ rule<> op;
+ rule<> sequence;
+ rule<> continuation;
+
+ constant = int_p;
+ op = plus || minus || times || divide;
+ ident = +range_p('a','z');
+ sequence = *(constant || op || ident);
+ continuation = opbrace >> sequence >> clbrace;
+
+ bool p0 = parse("1", constant, space_p).full;
+ bool p7 = parse("1 2", constant >> constant, space_p).full;
+ bool p4 = parse("+", op, space_p).full;
+ bool p5 = parse("+ +", op >> op, space_p).full;
+ bool p6 = parse("+ +", *op, space_p).full;
+ bool p2 = parse("1 2 +", *constant >> op, space_p).full;
+ bool p1 = parse("1 2", *constant, space_p).full;
+ bool p3 = parse("a b + 1 2 *", sequence, space_p).full;
+
+ BOOST_ASSERT(p0);
+ BOOST_ASSERT(p1);
+ BOOST_ASSERT(p2);
+ BOOST_ASSERT(p3);
 
 }
 
@@ -278,33 +278,33 @@
 template <class T, class Reg = nil>
 struct obj
 {
- //typedef
- obj()
- {
-
- }
-
- template <class Reg2>
- obj(obj<T, Reg2> const &q)
- {
- //getter = q.getter;
- }
-
- T &get()
- {
- throw;
- }
+ //typedef
+ obj()
+ {
+
+ }
+
+ template <class Reg2>
+ obj(obj<T, Reg2> const &q)
+ {
+ //getter = q.getter;
+ }
+
+ T &get()
+ {
+ throw;
+ }
 };
 
 template <class Tr>
 struct reg
 {
- template <class T>
- T &get(int number)
- {
- static int n = 42;
- return n;
- }
+ template <class T>
+ T &get(int number)
+ {
+ static int n = 42;
+ return n;
+ }
 };
 
 struct traits
@@ -314,8 +314,8 @@
 
 BOOST_AUTO_TEST_CASE(test_abstract)
 {
- obj<int> n = obj<int, reg<traits> >();
-// *n = 42;
+ obj<int> n = obj<int, reg<traits> >();
+// *n = 42;
 }
 
 


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