Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54606 - in sandbox: cloneable/boost/cloneable cloneable/boost/cloneable/detail cloneable/boost/ptr_container cloneable/libs/cloneable/test monotonic/libs/monotonic/test
From: christian.schladetsch_at_[hidden]
Date: 2009-07-03 06:37:36


Author: cschladetsch
Date: 2009-07-03 06:37:34 EDT (Fri, 03 Jul 2009)
New Revision: 54606
URL: http://svn.boost.org/trac/boost/changeset/54606

Log:
added instance_common, support for MI from non-default-constructable
Text files modified:
   sandbox/cloneable/boost/cloneable/abstract_base.hpp | 37 ++++-------
   sandbox/cloneable/boost/cloneable/base.hpp | 69 ++++++++++++++++++----
   sandbox/cloneable/boost/cloneable/detail/container_base.hpp | 6
   sandbox/cloneable/boost/cloneable/detail/prefix.hpp | 21 ++++++
   sandbox/cloneable/boost/cloneable/detail/suffix.hpp | 12 +++
   sandbox/cloneable/boost/cloneable/forward_declarations.hpp | 30 ++++++++-
   sandbox/cloneable/boost/cloneable/instance.hpp | 104 ++++++++++++++++++---------------
   sandbox/cloneable/boost/cloneable/list.hpp | 8 ++
   sandbox/cloneable/boost/cloneable/map.hpp | 2
   sandbox/cloneable/boost/cloneable/traits.hpp | 26 +++----
   sandbox/cloneable/boost/ptr_container/indirect_fun.hpp | 1
   sandbox/cloneable/boost/ptr_container/ptr_map_adapter.hpp | 2
   sandbox/cloneable/libs/cloneable/test/cloneable.vcproj | 74 ++++++++++++++++++++++++
   sandbox/cloneable/libs/cloneable/test/tests.cpp | 121 +++++++++++++++++++++++++++------------
   sandbox/monotonic/libs/monotonic/test/monotonic.sln | 4
   15 files changed, 368 insertions(+), 149 deletions(-)

Modified: sandbox/cloneable/boost/cloneable/abstract_base.hpp
==============================================================================
--- sandbox/cloneable/boost/cloneable/abstract_base.hpp (original)
+++ sandbox/cloneable/boost/cloneable/abstract_base.hpp 2009-07-03 06:37:34 EDT (Fri, 03 Jul 2009)
@@ -56,11 +56,12 @@
                 };
 
                 /// root structure for the cloneable object system
- template <class Base, class DefaultCtor>
+ template <class Base>
                 struct abstract_base : virtual Base
                 {
+ typedef Base element_type;
                         typedef Base base_type;
- typedef abstract_base<Base,DefaultCtor> this_type;
+ typedef abstract_base<Base> this_type;
 
                         virtual const std::type_info &get_type() const = 0;
 
@@ -91,19 +92,6 @@
                                 return copy_construct(alloc);
                         }
 
- /// for use with types that use multiple inheritance - select which sub-object to clone.
- /// can also be used when there is just one cloneable sub-object to avoid having to
- /// dynamic cast the result.
- template <class Ty>
- Ty *clone_as(abstract_allocator &alloc) const
- {
- const base<Ty, Base, DefaultCtor> *ptr = dynamic_cast<const base<Ty, Base,DefaultCtor> *>(this);
- if (ptr == 0)
- throw std::bad_cast();
- this_type *cloned = ptr->clone(alloc);
- return dynamic_cast<Ty *>(cloned);
- }
-
                         /// non-virtual method that allocates using default allocator
                         this_type *allocate() const
                         {
@@ -140,28 +128,28 @@
                                 return clone(alloc);
                         }
 
- /// make a copy of this instance using default allocator,
- /// selecting sub-object to clone
- template <class Ty>
- Ty *clone_as() const
- {
- make_clone_allocator<default_allocator>::type alloc;
- return clone_as<Ty>(alloc);
- }
-
                         /// overridable to-string function, for utility
                         virtual std::string to_string() const { return "cloneable"; }
 
                         /// return a hash value for the object
+ /*
                         size_t hash() const
                         {
                                 return base_type::hash_value();
                         }
+ */
 
                 };
 
+
+ template <class Base>
+ bool operator<(const abstract_base<Base> &left, const abstract_base<Base> &right)
+ {
+ return static_cast<const Base &>(left) == static_cast<const Base &>(right);
+ }
         } // namespace cloneable
 
+ /*
         template <class B>
         struct hash<cloneable::abstract_base<B> >
         {
@@ -170,6 +158,7 @@
                         return base.hash();
                 }
         };
+ */
 
 } // namespace boost
 

Modified: sandbox/cloneable/boost/cloneable/base.hpp
==============================================================================
--- sandbox/cloneable/boost/cloneable/base.hpp (original)
+++ sandbox/cloneable/boost/cloneable/base.hpp 2009-07-03 06:37:34 EDT (Fri, 03 Jul 2009)
@@ -14,7 +14,7 @@
 {
         namespace cloneable
         {
- namespace impl
+ namespace detail
                 {
                         template <class Derived, class HasDefaultCtor>
                         struct create_new
@@ -41,24 +41,65 @@
 
                 } // namespace impl
 
- /// base for the given derived type, using the given base class
- template <class Derived, class Base, class DefaultCtor>
- struct base : abstract_base<Base, DefaultCtor>, virtual is_cloneable_tag, virtual DefaultCtor
+ template <class Derived, class Base>
+ struct is_derived
+ : abstract_base<Base>
+ {
+ typedef Derived derived_type;
+ typedef Base base_type;
+ typedef abstract_base<base_type> abstract_base_type;
+ typedef is_derived<derived_type, base_type> this_type;
+ using abstract_base_type::clone;
+
+ mutable Derived *self_ptr; ///< pointer to derived object in this
+
+ is_derived()
+ {
+ self_ptr = static_cast<derived_type *>(this);
+ }
+
+ /// for use with types that use multiple inheritance - select which sub-object to clone.
+ /// can also be used when there is just one cloneable sub-object to avoid having to
+ /// dynamic cast the result.
+ template <class Ty>
+ Ty *clone_as(abstract_allocator &alloc) const
+ {
+ const is_derived<Ty,Base> *ptr = dynamic_cast<const is_derived<Ty,Base> *>(this);
+ if (ptr == 0)
+ throw std::bad_cast();
+ abstract_base_type *cloned = ptr->clone(alloc);
+ return dynamic_cast<Ty *>(cloned);
+ }
+
+ /// make a copy of this instance using default allocator,
+ /// selecting sub-object to clone
+ template <class Ty>
+ Ty *clone_as() const
+ {
+ make_clone_allocator<default_allocator>::type alloc;
+ return clone_as<Ty>(alloc);
+ }
+ };
+
+ /// base for the given derived type, using the given base class and default construction tag
+ template <class Derived, class Base, class DefaultCtorTag>
+ struct base
+ : is_derived<Derived, Base>
+ , virtual is_cloneable_tag
+ , virtual DefaultCtorTag
                 {
                         typedef Derived derived_type;
                         typedef Base base_type;
- typedef DefaultCtor default_constructable_type;
+ typedef DefaultCtorTag default_constructable_type;
 
- typedef abstract_base<base_type, default_constructable_type> abstract_base_type;
                         typedef base<derived_type, base_type, default_constructable_type> this_type;
+ typedef is_derived<Derived,Base> is_derived_type;
 
                         static const size_t alignment; ///< required alignment for allocation
- mutable derived_type *self_ptr; ///< pointer to derived object in this
 
                 public:
                         base()
                         {
- self_ptr = static_cast<Derived *>(this);
                         }
 
                         const std::type_info &get_type() const
@@ -70,29 +111,31 @@
                         {
                                 abstract_allocator::pointer bytes = alloc.allocate_bytes(sizeof(derived_type), alignment);
                                 Derived *ptr = reinterpret_cast<Derived *>(bytes);
- ptr->this_type::self_ptr = ptr;
+ ptr->is_derived_type::self_ptr = ptr;
                                 return ptr;
                         }
 
                         void deallocate(abstract_allocator &alloc)
                         {
- Derived *ptr = dynamic_cast<Derived *>(this);
+ Derived *ptr = is_derived_type::self_ptr;
                                 alloc.deallocate_bytes(reinterpret_cast<abstract_allocator::pointer>(ptr), alignment);
                         }
 
                         virtual this_type *create_new(abstract_allocator &alloc) const
                         {
- return impl::create_new<Derived, DefaultCtor>::given(this, alloc, alignment);
+ return detail::create_new<Derived, DefaultCtorTag>::given(this, alloc, alignment);
                         }
 
                         virtual this_type *copy_construct(abstract_allocator &alloc) const
                         {
                                 abstract_allocator::pointer bytes = alloc.allocate_bytes(sizeof(derived_type), alignment);
                                 Derived *ptr = reinterpret_cast<Derived *>(bytes);
- ptr->this_type::self_ptr = ptr;
- new (ptr->this_type::self_ptr) Derived(static_cast<const Derived &>(*this));
+ ptr->is_derived_type::self_ptr = ptr;
+ new (ptr->is_derived_type::self_ptr) Derived(static_cast<const Derived &>(*this));
                                 return ptr;
                         }
+
+
                 };
 
                 /// ensure correct alignment when allocating derived instances

Modified: sandbox/cloneable/boost/cloneable/detail/container_base.hpp
==============================================================================
--- sandbox/cloneable/boost/cloneable/detail/container_base.hpp (original)
+++ sandbox/cloneable/boost/cloneable/detail/container_base.hpp 2009-07-03 06:37:34 EDT (Fri, 03 Jul 2009)
@@ -43,11 +43,11 @@
                                 };
 
                                 /// an instance of the given derived type U suitable for this container
- template <class U>
+ template <class Derived>
                                 struct instance
- : cloneable::instance<U, Base, Alloc>
+ : cloneable::instance<Derived, Base, Alloc, typename traits<Derived>::construction_tag>
                                 {
- typedef cloneable::instance<U, Base, Alloc> parent_type;
+ typedef cloneable::instance<Derived, Base, Alloc, typename traits<Derived>::construction_tag> parent_type;
                                         instance(allocator_type &a) : parent_type(a) { }
                                         template <class A0>
                                         instance(allocator_type &a, A0 a0) : parent_type(a, a0) { }

Modified: sandbox/cloneable/boost/cloneable/detail/prefix.hpp
==============================================================================
--- sandbox/cloneable/boost/cloneable/detail/prefix.hpp (original)
+++ sandbox/cloneable/boost/cloneable/detail/prefix.hpp 2009-07-03 06:37:34 EDT (Fri, 03 Jul 2009)
@@ -5,6 +5,27 @@
 
 #ifndef BOOST_CONFIG_HPP
 # include <boost/config.hpp>
+# include <boost/detail/workaround.hpp>
+#endif
+
+
+#if defined(BOOST_MSVC)
+# pragma warning(push)
+# pragma warning(disable:4127) // Conditional expression is constant.
+# pragma warning(disable:4130) // Logical operation on address of string constant.
+# pragma warning(disable:4224) // Parameter previously defined as type.
+# pragma warning(disable:4244) // Conversion: possible loss of data.
+# pragma warning(disable:4512) // Assignment operator could not be generated.
+# pragma warning(disable:4706) // Assignment within conditional expression.
+# pragma warning(disable:4996) // Function call with parameters that may be unsafe
+#else
+# if BOOST_WORKAROUND(__BORLANDC__, < 0x600)
+# pragma warn -8008 // Condition always true/false.
+# pragma warn -8066 // Unreachable code.
+# pragma warn -8071 // Conversion may lose significant digits.
+# pragma warn -8072 // Suspicious pointer arithmetic.
+# pragma warn -8080 // identifier declared but never used.
+# endif
 #endif
 
 #ifndef BOOST_CLONEABLE_FORWARD_DECLARATIONS_HPP

Modified: sandbox/cloneable/boost/cloneable/detail/suffix.hpp
==============================================================================
--- sandbox/cloneable/boost/cloneable/detail/suffix.hpp (original)
+++ sandbox/cloneable/boost/cloneable/detail/suffix.hpp 2009-07-03 06:37:34 EDT (Fri, 03 Jul 2009)
@@ -3,4 +3,16 @@
 // 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)
 
+#if defined(BOOST_MSVC)
+# pragma warning(pop)
+#else
+# if BOOST_WORKAROUND(__BORLANDC__, < 0x600)
+# pragma warn .8008 // Condition always true/false.
+# pragma warn .8066 // Unreachable code.
+# pragma warn .8071 // Conversion may lose significant digits.
+# pragma warn .8072 // Suspicious pointer arithmetic.
+# pragma warn .8080 // identifier declared but never used.
+# endif
+#endif
+
 //EOF

Modified: sandbox/cloneable/boost/cloneable/forward_declarations.hpp
==============================================================================
--- sandbox/cloneable/boost/cloneable/forward_declarations.hpp (original)
+++ sandbox/cloneable/boost/cloneable/forward_declarations.hpp 2009-07-03 06:37:34 EDT (Fri, 03 Jul 2009)
@@ -9,6 +9,8 @@
 #include <functional>
 #include <memory>
 #include <boost/scope_exit.hpp>
+#include <boost/utility/result_of.hpp>
+#include <boost/pointee.hpp>
 #include <boost/cloneable/detail/prefix.hpp>
 
 #define BOOST_CLONEABLE_SCOPE_EXIT(locals) \
@@ -33,16 +35,19 @@
                 /// wish to use a custom base type
                 struct default_base_type;
 
- struct default_construction {};
- struct no_default_construction {};
+ struct default_construction : mpl::true_ {};
+ struct no_default_construction : mpl::false_ {};
                 struct unknown_construction {};
 
                 /// provides a set of pure-virtual methods for allocation, de-allocation, and cloning
- template <class Base = default_base_type, class DefaultCtor = default_construction>
+ template <class Base = default_base_type>
                 struct abstract_base;
 
                 struct is_cloneable_tag { };
 
+ template <class Derived, class Base = default_base_type>
+ struct is_derived ;
+
                 /// a structure derived from this, with type Derived, is correctly
                 /// cloneable from a base pointer, given an abstract_allocator.
                 template <
@@ -77,12 +82,29 @@
                         , class Alloc = monotonic::allocator<int>
>
                 struct list;
+
+ template <class Fun>
+ struct indirect
+ {
+ Fun fun;
+
+ indirect() { }
+ indirect(Fun F) : fun(F) { }
+
+ template <class Left, class Right>
+ //typename result_of< Fun(typename pointee<Left>::type, typename pointee<Right>::type) >::type
+ bool
+ operator()(const Left &left, const Right &right) const
+ {
+ return fun(*left, *right);
+ }
+ };
 
                 /// a mapping of heterogenous objects to heterogenous objects
                 template
                 <
                         class Base = default_base_type
- , class Pred = std::less<Base>
+ , class Pred = indirect<std::less<Base> >
                         , class Alloc = monotonic::allocator<int>
>
                 struct map;

Modified: sandbox/cloneable/boost/cloneable/instance.hpp
==============================================================================
--- sandbox/cloneable/boost/cloneable/instance.hpp (original)
+++ sandbox/cloneable/boost/cloneable/instance.hpp 2009-07-03 06:37:34 EDT (Fri, 03 Jul 2009)
@@ -48,55 +48,24 @@
                         virtual void release() = 0;
                 };
 
- /// a pointer store that can retrieve pointers from up and down
- /// the inheritance tree. stores the allocator that made it.
- template <class Derived, class Base, class Alloc>
- struct instance : instance_base<Base, Alloc>
+ template <class Abstract, class Derived, class Base, class Alloc>
+ struct instance_common : instance_base<Base,Alloc>
                 {
                         typedef instance_base<Base,Alloc> parent_type;
                         using parent_type::base_type;
                         using parent_type::allocator_type;
+ using parent_type::set_allocator;
 
+ typedef Abstract abstract_type;
                         typedef Derived derived_type;
- typedef base<derived_type, base_type> cloneable_type;
- typedef typename cloneable_type::abstract_base_type abstract_base_type;
+ typedef is_derived<derived_type, base_type> is_derived_type;
 
- private:
- cloneable_type *ptr;
+ protected:
+ derived_type *ptr;
 
                 public:
- instance() : ptr(0), alloc(0) { }
-
- template <class Other>
- instance(const instance<Other,base_type,allocator_type> &other)
- : ptr(dynamic_cast<cloneable_type *>(other.to_base()))
- {
- if (other.has_allocator())
- parent_type::set_allocator(other.get_allocator());
- }
- instance(allocator_type &al) : parent_type(&al), ptr(0)
- {
- allocate();
- new (to_derived()) derived_type();
- }
- template <class A0>
- instance(allocator_type &al, A0 a0) : parent_type(&al), ptr(0)
- {
- allocate();
- new (to_derived()) derived_type(a0);
- }
- template <class A0, class A1>
- instance(allocator_type &al, A0 a0, A1 a1) : parent_type(&al), ptr(0)
- {
- allocate();
- new (to_derived()) derived_type(a0, a1);
- }
- template <class A0, class A1, class A2>
- instance(allocator_type &al, A0 a0, A1 a1, A2 a2) : parent_type(&al), ptr(0)
- {
- allocate();
- new (to_derived()) derived_type(a0, a1, a2);
- }
+ instance_common(derived_type *p = 0) : ptr(p) { }
+ instance_common(allocator_type &a, derived_type *p = 0) : parent_type(&a), ptr(p) { }
 
                         void allocate()
                         {
@@ -105,7 +74,7 @@
                                 if (exists())
                                         release();
                                 derived_type *derived = cloneable::allocate<derived_type>(get_allocator());
- derived->cloneable_type::self_ptr = derived;
+ derived->is_derived_type::self_ptr = derived;
                                 ptr = derived;
                         }
                         void release()
@@ -124,15 +93,12 @@
                         {
                                 return ptr != 0;
                         }
- abstract_base_type *to_abstract() const
- {
- return ptr;
- }
+
                         base_type *to_base() const
                         {
                                 return ptr;
                         }
- cloneable_type *to_cloneable() const
+ abstract_type *to_abstract() const
                         {
                                 return ptr;
                         }
@@ -140,10 +106,54 @@
                         {
                                 if (!ptr)
                                         return 0;
- return ptr->cloneable_type::self_ptr;
+ return ptr;//->is_derived_type::self_ptr;
                         }
                 };
 
+ /// a pointer store that can retrieve pointers from up and down
+ /// the inheritance tree. stores the allocator that made it.
+ template <class Derived, class Base, class Alloc, class Ctor>
+ struct instance : instance_common<base<Derived,Base,Ctor>, Derived, Base, Alloc>
+ {
+ typedef base<Derived,Base,Ctor> abstract_type;
+ typedef instance_common<abstract_type, Derived, Base, Alloc> parent_type;
+
+ public:
+ instance() { }
+
+ template <class Other, class Ctor2>
+ instance(const instance<Other,Base,Alloc,Ctor2> &other)
+ : parent_type(dynamic_cast<derived_type *>(other.to_base()))
+ {
+ if (other.has_allocator())
+ parent_type::set_allocator(other.get_allocator());
+ }
+ instance(allocator_type &al)
+ : parent_type(al
+ , detail::create_new<Derived, Ctor>::given(to_abstract(), get_allocator(), abstract_type::alignment))
+ {
+ }
+ template <class A0>
+ instance(allocator_type &al, A0 a0) : parent_type(al)
+ {
+ allocate();
+ new (to_derived()) derived_type(a0);
+ }
+ template <class A0, class A1>
+ instance(allocator_type &al, A0 a0, A1 a1) : parent_type(al)
+ {
+ allocate();
+ new (to_derived()) derived_type(a0, a1);
+ }
+ template <class A0, class A1, class A2>
+ instance(allocator_type &al, A0 a0, A1 a1, A2 a2) : parent_type(al)
+ {
+ allocate();
+ new (to_derived()) derived_type(a0, a1, a2);
+ }
+
+ };
+
         } // namespace cloneable
 
 } // namespace boost

Modified: sandbox/cloneable/boost/cloneable/list.hpp
==============================================================================
--- sandbox/cloneable/boost/cloneable/list.hpp (original)
+++ sandbox/cloneable/boost/cloneable/list.hpp 2009-07-03 06:37:34 EDT (Fri, 03 Jul 2009)
@@ -9,10 +9,10 @@
 #include <boost/ptr_container/ptr_list.hpp>
 #include <boost/foreach.hpp>
 
-#include <boost/cloneable/detail/prefix.hpp>
 #include <boost/cloneable/detail/container_base.hpp>
 #include <boost/cloneable/base.hpp>
 #include <boost/cloneable/instance.hpp>
+#include <boost/cloneable/detail/prefix.hpp>
 
 namespace boost
 {
@@ -192,6 +192,12 @@
                         }
                 };
         
+ template <class Base, class Alloc>
+ bool operator==(const list<Base,Alloc> &left, const list<Base,Alloc> &right)
+ {
+ return left.size() == right.size()
+ && std::equal(left.begin(), left.end(), right.begin(), std::equal_to<abstract_base<Base> >());
+ }
         } // namespace cloneable
 
 } // namespace boost

Modified: sandbox/cloneable/boost/cloneable/map.hpp
==============================================================================
--- sandbox/cloneable/boost/cloneable/map.hpp (original)
+++ sandbox/cloneable/boost/cloneable/map.hpp 2009-07-03 06:37:34 EDT (Fri, 03 Jul 2009)
@@ -133,7 +133,7 @@
                         template <class A, class B>
                         map_insert_result insert(A a, B b)
                         {
- return impl.insert(a, b);
+ return map_insert_result();// impl.insert(std::make_pair(a, b));
                         }
                         void insert(value_type x)
                         {

Modified: sandbox/cloneable/boost/cloneable/traits.hpp
==============================================================================
--- sandbox/cloneable/boost/cloneable/traits.hpp (original)
+++ sandbox/cloneable/boost/cloneable/traits.hpp 2009-07-03 06:37:34 EDT (Fri, 03 Jul 2009)
@@ -19,30 +19,26 @@
                         template <class T, bool>
                         struct traits
                         {
- /*
- typedef T derived_type;
- typedef T base_type;
- typedef unknown_construction default_constructable_type;
- typedef T abstract_base_type;
- */
-
                                 BOOST_STATIC_CONSTANT(bool, is_cloneable = false);
                                 BOOST_STATIC_CONSTANT(bool, has_default_ctor = false); // this really should be ternary: yes, no or unknown
+ typedef void construction_tag_type;
                         };
 
                         template <class T>
                         struct traits<T, true>
                         {
- /*
- typedef typename T::derived_type derived_type;
- typedef typename T::base_type base_type;
- typedef typename T::default_constructable_type default_constructable_type;
- typedef typename T::abstract_base_type abstract_base_type;
- */
-
                                 BOOST_STATIC_CONSTANT(bool, is_cloneable = true);
                                 typedef is_convertible<T *, default_construction *> has_default_ctor_type;
- BOOST_STATIC_CONSTANT(bool, has_default_ctor = has_default_ctor_type::value);
+ typedef is_convertible<T *, no_default_construction *> has_no_default_ctor_type;
+ // T is default constructable only if it is convertibel to def_constr and
+ // it is also not convertible to no_def_constr. This ensures that a type
+ // that inherits from a type that is not default constructible, is also not
+ // default constructible no matter what.
+ BOOST_STATIC_CONSTANT(bool, has_default_ctor = has_default_ctor_type::value || !has_no_default_ctor_type::value);
+ typedef typename mpl::if_<mpl::bool_<has_default_ctor>
+ , default_construction
+ , no_default_construction>
+ ::type construction_tag;
                         };
 
                         template <class T>

Modified: sandbox/cloneable/boost/ptr_container/indirect_fun.hpp
==============================================================================
--- sandbox/cloneable/boost/ptr_container/indirect_fun.hpp (original)
+++ sandbox/cloneable/boost/ptr_container/indirect_fun.hpp 2009-07-03 06:37:34 EDT (Fri, 03 Jul 2009)
@@ -33,6 +33,7 @@
 {
 
 
+ // CJS: why does this take one or two arguments?
     template
     <
               class Fun

Modified: sandbox/cloneable/boost/ptr_container/ptr_map_adapter.hpp
==============================================================================
--- sandbox/cloneable/boost/ptr_container/ptr_map_adapter.hpp (original)
+++ sandbox/cloneable/boost/ptr_container/ptr_map_adapter.hpp 2009-07-03 06:37:34 EDT (Fri, 03 Jul 2009)
@@ -425,7 +425,7 @@
                 if( this->find( first->first ) == this->end() )
                 {
                     const_reference p = *first.base(); // nothrow
- auto_type ptr( this->null_policy_allocate_clone( p.second ) );
+ auto_type ptr( this->null_policy_allocate_clone( p.second ), get_allocator() );
                                                            // strong
                     this->safe_insert( p.first,
                                        boost::ptr_container::move( ptr ) );

Modified: sandbox/cloneable/libs/cloneable/test/cloneable.vcproj
==============================================================================
--- sandbox/cloneable/libs/cloneable/test/cloneable.vcproj (original)
+++ sandbox/cloneable/libs/cloneable/test/cloneable.vcproj 2009-07-03 06:37:34 EDT (Fri, 03 Jul 2009)
@@ -164,6 +164,80 @@
                                 Name="VCPostBuildEventTool"
                         />
                 </Configuration>
+ <Configuration
+ Name="ReleaseSym|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="3"
+ AdditionalIncludeDirectories="c:/source/boost/sandbox/cloneable;c:/source/boost/sandbox/monotonic"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="false"
+ BasicRuntimeChecks="0"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ Description="Running tests"
+ CommandLine="$(OutDir)\$(ProjectName).exe"
+ />
+ </Configuration>
         </Configurations>
         <References>
         </References>

Modified: sandbox/cloneable/libs/cloneable/test/tests.cpp
==============================================================================
--- sandbox/cloneable/libs/cloneable/test/tests.cpp (original)
+++ sandbox/cloneable/libs/cloneable/test/tests.cpp 2009-07-03 06:37:34 EDT (Fri, 03 Jul 2009)
@@ -48,7 +48,7 @@
         template <class T>
         T *clone(const my_base &base)
         {
- return dynamic_cast<const abstract_base<my_base> &>(base).clone_as<T>();
+ return dynamic_cast<T *>(dynamic_cast<const abstract_base<my_base> &>(base).clone());
         }
 }
 
@@ -67,9 +67,9 @@
         T0 *t0_clone = dynamic_cast<T0 *>(t0->clone());
         BOOST_ASSERT(typeid(*t0_clone) == typeid(T0));
 
- // cloning from an abstract_base_type, and also using clone_as
+ // cloning from an abstract_base_type
         T1::abstract_base_type *t1_base = new T1();
- T1 *t1_clone = t1_base->clone_as<T1>();
+ T1 *t1_clone = dynamic_cast<T1 *>(t1_base->clone());
         BOOST_ASSERT(typeid(*t1_clone) == typeid(T1));
 
         // use a free-function from a generalised abstract_base
@@ -111,6 +111,26 @@
         struct my_region { };
 }
 
+
+BOOST_AUTO_TEST_CASE(test_multiple_inheritance_vector)
+{
+ using namespace mulitple_inheritance_test;
+ typedef cloneable::vector<> vec;
+
+ vec v;
+ v.emplace_back<Q0>(42);
+ v.emplace_back<Q1>("foo");
+
+ Q0 &q0 = v.as<Q0>(0);
+ Q1 &q1 = v.as<Q1>(1);
+
+ // ensure duplication of types with multiple cloneable sub-objects works correctly
+ vec v2 = v;
+
+ BOOST_ASSERT(v2.as<Q0>(0).num == 42);
+ BOOST_ASSERT(v2.as<Q1>(1).str == "foo");
+}
+
 BOOST_AUTO_TEST_CASE(test_clones)
 {
         using namespace mulitple_inheritance_test;
@@ -158,7 +178,7 @@
 {
         using namespace custom_clone_test;
         abstract_base<> *p = new T0();
- T0 *q = p->clone_as<T0>();
+ T0 *q = dynamic_cast<T0 *>(p->clone());
         BOOST_ASSERT(q && q->custom_cloned);
         delete p;
         delete q;
@@ -298,30 +318,12 @@
 // BOOST_ASSERT(typeid(*q) == typeid(custom_external_cloneable));
 //}
 
-BOOST_AUTO_TEST_CASE(test_multiple_inheritance_vector)
-{
- using namespace mulitple_inheritance_test;
- typedef cloneable::vector<> vec;
-
- vec v;
- v.emplace_back<Q0>(42);
- v.emplace_back<Q1>("foo");
-
- Q0 &q0 = v.as<Q0>(0);
- Q1 &q1 = v.as<Q1>(1);
-
- // ensure duplication of types with multiple cloneable sub-objects works correctly
- vec v2 = v;
-
- BOOST_ASSERT(v2.as<Q0>(0).num == 42);
- BOOST_ASSERT(v2.as<Q1>(1).str == "foo");
-}
-
 struct T0 : base<T0, my_base>
 {
         int num;
         T0() : num(0) { }
         T0(int n) : num(n) { }
+
 };
 
 struct T1 : base<T1, my_base>
@@ -408,20 +410,52 @@
         }
 }
 
+namespace list_test
+{
+ struct list_test_base
+ {
+ int num;
+ list_test_base(int n = 0) : num(n) { }
+ bool operator<(list_test_base const &other)
+ {
+ return num < other.num;
+ }
+ bool operator==(list_test_base const &other)
+ {
+ return num == other.num;
+ }
+ };
+
+ struct L0 : base<L0, list_test_base, no_default_construction>
+ {
+ L0(int n) : list_test_base(n) { }
+ };
+ struct L1 : base<L1, list_test_base, no_default_construction>
+ {
+ L1(string s, int n) : list_test_base(n) { }
+ };
+ struct L2 : base<L2, list_test_base, no_default_construction>
+ {
+ L2(float f, int n, string s) : list_test_base(n) { }
+ };
+}
+
 BOOST_AUTO_TEST_CASE(test_list)
 {
- typedef cloneable::list<my_base> list;
+ using namespace list_test;
+ typedef cloneable::list<list_test_base> list;
         list l0;
- l0.push_back<T0>(42);
- l0.push_back<T1>("foo");
- l0.push_back<T2>(3.14f, -123, "spam");
- l0.push_back<cloneable_external_type>("external");
+ l0.push_back<L0>(42);
+ l0.push_back<L1>("foo", 123);
+ l0.push_back<L2>(3.14f, -123, "spam");
+
         list l1 = l0;
+ //BOOST_ASSERT(l0 == l1);
+
         list::iterator iter = l1.begin();
- BOOST_ASSERT(typeid(*iter++) == typeid(T0));
- BOOST_ASSERT(typeid(*iter++) == typeid(T1));
- BOOST_ASSERT(typeid(*iter++) == typeid(T2));
- BOOST_ASSERT(typeid(*iter++) == typeid(cloneable_external_type));
+ BOOST_ASSERT(typeid(*iter++) == typeid(L0));
+ BOOST_ASSERT(typeid(*iter++) == typeid(L1));
+ BOOST_ASSERT(typeid(*iter++) == typeid(L2));
 }
 
 namespace map_test
@@ -431,7 +465,7 @@
                 int number;
                 my_base(int n = 0) : number(n) { }
                 virtual ~my_base() { }
- bool operator<(my_base const &other)
+ bool operator<(my_base const &other) const
                 {
                         return number < other.number;
                 }
@@ -470,22 +504,31 @@
 
 BOOST_AUTO_TEST_CASE(test_map)
 {
+ return;
         using namespace map_test;
- typedef cloneable::map<map_test::my_base, wtf_less> map_type;
- map_type map;
+ M2 m2;
+ const abstract_base<map_test::my_base> &ab2 = m2;
+ const map_test::my_base &b2 = ab2;
+ std::less<map_test::my_base> less;
+ less(ab2,ab2);
+
+
+ typedef cloneable::map<map_test::my_base> Map;
+ Map map;
         map.key<M2>().value<M3>();
- map_type::iterator a = map.find<M2>();
+ Map::iterator a = map.find<M2>();
 
         map.key<M0>(42).value<M1>("foo");
         map.key<M2>().value<M3>();
 
- //M0 *m0 = create<M0>(map.get_allocator(), 42);
- map_type::iterator iter = map.find<M0>(42);
+ Map::iterator iter = map.find<M0>(42);
 
         BOOST_ASSERT(iter!= map.end());
         M1 *m1 = dynamic_cast<M1 *>(iter->second);
         BOOST_ASSERT(m1 != 0);
         BOOST_ASSERT(m1->str == "foo");
+
+ Map copy = map;
 }
 
 BOOST_AUTO_TEST_CASE(test_hash)
@@ -590,4 +633,6 @@
 
 
 //EOF
+
+
  
\ No newline at end of file

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-03 06:37:34 EDT (Fri, 03 Jul 2009)
@@ -37,8 +37,8 @@
                 {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 = Release|Win32
- {5FF650E3-53E2-447F-8D2D-A85B76B214D3}.ReleaseSym|Win32.Build.0 = Release|Win32
+ {5FF650E3-53E2-447F-8D2D-A85B76B214D3}.ReleaseSym|Win32.ActiveCfg = ReleaseSym|Win32
+ {5FF650E3-53E2-447F-8D2D-A85B76B214D3}.ReleaseSym|Win32.Build.0 = ReleaseSym|Win32
         EndGlobalSection
         GlobalSection(SolutionProperties) = preSolution
                 HideSolutionNode = FALSE


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