Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54602 - in sandbox/cloneable: boost/cloneable boost/ptr_container/detail libs/cloneable/test
From: christian.schladetsch_at_[hidden]
Date: 2009-07-02 20:14:16


Author: cschladetsch
Date: 2009-07-02 20:14:15 EDT (Thu, 02 Jul 2009)
New Revision: 54602
URL: http://svn.boost.org/trac/boost/changeset/54602

Log:
added abstract_base<>::get_type

Text files modified:
   sandbox/cloneable/boost/cloneable/abstract_base.hpp | 3
   sandbox/cloneable/boost/cloneable/base.hpp | 5 +
   sandbox/cloneable/boost/cloneable/instance.hpp | 4
   sandbox/cloneable/boost/cloneable/set.hpp | 9 +
   sandbox/cloneable/boost/ptr_container/detail/reversible_ptr_container.hpp | 2
   sandbox/cloneable/boost/ptr_container/detail/scoped_deleter.hpp | 2
   sandbox/cloneable/libs/cloneable/test/cloneable.vcproj | 180 ++++++++++++++++++++++++++++++++++++++++
   sandbox/cloneable/libs/cloneable/test/tests.cpp | 22 ++++
   8 files changed, 218 insertions(+), 9 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-02 20:14:15 EDT (Thu, 02 Jul 2009)
@@ -7,6 +7,7 @@
 #define BOOST_CLONEABLE_COMMON_BASE_HPP
 
 #include <string>
+#include <typeinfo>
 #include <boost/functional/hash_fwd.hpp>
 #include <boost/cloneable/detail/prefix.hpp>
 #include <boost/cloneable/abstract_allocator.hpp>
@@ -61,6 +62,8 @@
                         typedef Base base_type;
                         typedef abstract_base<Base,DefaultCtor> this_type;
 
+ virtual const std::type_info &get_type() const = 0;
+
                         /// make storage for a new instance, but do not invoke any constructor
                         virtual this_type *allocate(abstract_allocator &) const = 0;
 

Modified: sandbox/cloneable/boost/cloneable/base.hpp
==============================================================================
--- sandbox/cloneable/boost/cloneable/base.hpp (original)
+++ sandbox/cloneable/boost/cloneable/base.hpp 2009-07-02 20:14:15 EDT (Thu, 02 Jul 2009)
@@ -61,6 +61,11 @@
                                 self_ptr = static_cast<Derived *>(this);
                         }
 
+ const std::type_info &get_type() const
+ {
+ return typeid(derived_type);
+ }
+
                         virtual this_type *allocate(abstract_allocator &alloc) const
                         {
                                 abstract_allocator::pointer bytes = alloc.allocate_bytes(sizeof(derived_type), alignment);

Modified: sandbox/cloneable/boost/cloneable/instance.hpp
==============================================================================
--- sandbox/cloneable/boost/cloneable/instance.hpp (original)
+++ sandbox/cloneable/boost/cloneable/instance.hpp 2009-07-02 20:14:15 EDT (Thu, 02 Jul 2009)
@@ -80,6 +80,10 @@
                                 ptr = 0;
                         }
 
+ bool exists() const
+ {
+ return ptr != 0;
+ }
                         abstract_base_type *to_abstract() const
                         {
                                 return ptr;

Modified: sandbox/cloneable/boost/cloneable/set.hpp
==============================================================================
--- sandbox/cloneable/boost/cloneable/set.hpp (original)
+++ sandbox/cloneable/boost/cloneable/set.hpp 2009-07-02 20:14:15 EDT (Thu, 02 Jul 2009)
@@ -23,10 +23,10 @@
                 template <class Base, class Pred, class Alloc>
                 struct set
                 {
- typedef typename detail::make_clone_allocator<Alloc>::type allocator_type;
                         typedef Base base_type;
                         typedef Pred predicate_type;
                         typedef abstract_base<Base> abstract_base_type;
+ typedef typename detail::make_clone_allocator<Alloc>::type allocator_type;
 
                         typedef ptr_set<abstract_base_type, predicate_type, allocator, allocator_type> implementation;
 
@@ -188,10 +188,13 @@
                         template <class U>
                         iterator find_instance(instance<U,base_type,allocator_type> value)
                         {
- iterator found = impl.find(value.to_abstract());
+ if (!value.exists())
+ return end();
+ iterator found = impl.find(*value.to_abstract());
                                 if (found == impl.end())
                                         return found;
- if (typeid(&*found) == typeid(U))
+ std::type_info const &found_type = found->get_type();
+ if (found_type == typeid(U))
                                         return found;
                                 return impl.end();
                         }

Modified: sandbox/cloneable/boost/ptr_container/detail/reversible_ptr_container.hpp
==============================================================================
--- sandbox/cloneable/boost/ptr_container/detail/reversible_ptr_container.hpp (original)
+++ sandbox/cloneable/boost/ptr_container/detail/reversible_ptr_container.hpp 2009-07-02 20:14:15 EDT (Thu, 02 Jul 2009)
@@ -336,7 +336,7 @@
             if( first == last )
                 return;
 
- scoped_deleter sd( first, last );
+ scoped_deleter sd( first, last, get_allocator() );
             insert_clones_and_release( sd );
         }
 

Modified: sandbox/cloneable/boost/ptr_container/detail/scoped_deleter.hpp
==============================================================================
--- sandbox/cloneable/boost/ptr_container/detail/scoped_deleter.hpp (original)
+++ sandbox/cloneable/boost/ptr_container/detail/scoped_deleter.hpp 2009-07-02 20:14:15 EDT (Thu, 02 Jul 2009)
@@ -60,7 +60,6 @@
             }
 
 
-
             template< class InputIterator, class Alloc2 >
             scoped_deleter ( InputIterator first, InputIterator last, Alloc2 &a ) // strong
                 : ptrs_( new T*[ std::distance(first,last) ] ),
@@ -71,7 +70,6 @@
                     add( CloneAllocator::allocate_clone_from_iterator( first, alloc ) );
                 BOOST_ASSERT( stored_ > 0 );
             }
-
             
             
             ~scoped_deleter()

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-02 20:14:15 EDT (Thu, 02 Jul 2009)
@@ -171,6 +171,10 @@
                 <Filter
                         Name="boost"
>
+ <File
+ RelativePath="..\..\..\boost\any.hpp"
+ >
+ </File>
                         <Filter
                                 Name="cloneable"
>
@@ -255,6 +259,182 @@
                                         </File>
                                 </Filter>
                         </Filter>
+ <Filter
+ Name="ptr_container"
+ >
+ <File
+ RelativePath="..\..\..\boost\ptr_container\clone_allocator.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\exception.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\indirect_fun.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\nullable.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\ptr_array.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\ptr_circular_buffer.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\ptr_container.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\ptr_deque.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\ptr_inserter.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\ptr_list.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\ptr_map.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\ptr_map_adapter.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\ptr_sequence_adapter.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\ptr_set.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\ptr_set_adapter.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\ptr_unordered_map.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\ptr_unordered_set.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\ptr_vector.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\serialize_ptr_array.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\serialize_ptr_circular_buffer.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\serialize_ptr_container.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\serialize_ptr_deque.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\serialize_ptr_list.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\serialize_ptr_map.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\serialize_ptr_set.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\serialize_ptr_unordered_map.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\serialize_ptr_unordered_set.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\serialize_ptr_vector.hpp"
+ >
+ </File>
+ <Filter
+ Name="detail"
+ >
+ <File
+ RelativePath="..\..\..\boost\ptr_container\detail\associative_ptr_container.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\detail\default_deleter.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\detail\is_convertible.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\detail\map_iterator.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\detail\meta_functions.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\detail\move.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\detail\reversible_ptr_container.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\detail\scoped_deleter.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\detail\serialize_ptr_map_adapter.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\detail\serialize_reversible_cont.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\detail\serialize_xml_names.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\detail\static_move_ptr.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\detail\throw_exception.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\ptr_container\detail\void_ptr_iterator.hpp"
+ >
+ </File>
+ </Filter>
+ </Filter>
                 </Filter>
                 <Filter
                         Name="doc"

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-02 20:14:15 EDT (Thu, 02 Jul 2009)
@@ -550,14 +550,30 @@
         set.emplace<S1>(2);
         set.emplace<S2>(3);
         set.emplace<S2>(4);
+ /*
+ BOOST_FOREACH(Set::value_type const &val, set)
+ {
+ BOOST_ASSERT(val != 0);
+ }
+ */
+ Set::const_iterator A = set.begin(), B = set.end();
+ for (; A != B; ++A)
+ {
+ const set_base *base = &*A;
+ BOOST_ASSERT(base);
+ }
+
+ BOOST_ASSERT(set.size() == 4);
+ BOOST_ASSERT(set.find<S0>(1) != set.end());
+ BOOST_ASSERT(set.find<set_base>(2) != set.end());
 
         Set copy = set;
 
 // BOOST_ASSERT(copy == set);
 
- BOOST_ASSERT(set.size() == 4);
- BOOST_ASSERT(set.find<S0>(1) != set.end());
- BOOST_ASSERT(set.find<set_base>(2) != set.end());
+ BOOST_ASSERT(copy.size() == 4);
+ BOOST_ASSERT(copy.find<S0>(1) != copy.end());
+ BOOST_ASSERT(copy.find<set_base>(2) != copy.end());
 
         Set::iterator found;
         found = set.find<set_base>(1);


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