Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54528 - in sandbox/monotonic: boost/heterogenous boost/heterogenous/detail libs/monotonic/test/clones
From: christian.schladetsch_at_[hidden]
Date: 2009-06-30 05:14:15


Author: cschladetsch
Date: 2009-06-30 05:14:15 EDT (Tue, 30 Jun 2009)
New Revision: 54528
URL: http://svn.boost.org/trac/boost/changeset/54528

Log:
added detail/pointer.hpp

Added:
   sandbox/monotonic/boost/heterogenous/detail/pointer.hpp (contents, props changed)
Text files modified:
   sandbox/monotonic/boost/heterogenous/detail/allocation.hpp | 58 ++++++++-------------------------------
   sandbox/monotonic/boost/heterogenous/map.hpp | 14 ++++----
   sandbox/monotonic/boost/heterogenous/vector.hpp | 8 ++--
   sandbox/monotonic/libs/monotonic/test/clones/clones.vcproj | 4 ++
   sandbox/monotonic/libs/monotonic/test/clones/tests.cpp | 2
   5 files changed, 28 insertions(+), 58 deletions(-)

Modified: sandbox/monotonic/boost/heterogenous/detail/allocation.hpp
==============================================================================
--- sandbox/monotonic/boost/heterogenous/detail/allocation.hpp (original)
+++ sandbox/monotonic/boost/heterogenous/detail/allocation.hpp 2009-06-30 05:14:15 EDT (Tue, 30 Jun 2009)
@@ -3,11 +3,12 @@
 // 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)
 
-#ifndef BOOST_HETEROGENOUS_DETAIL_CONTAINER_BASE_HPP
-#define BOOST_HETEROGENOUS_DETAIL_CONTAINER_BASE_HPP
+#ifndef BOOST_HETEROGENOUS_DETAIL_ALLOCATION_HPP
+#define BOOST_HETEROGENOUS_DETAIL_ALLOCATION_HPP
 
 #include <boost/heterogenous/detail/prefix.hpp>
 #include <boost/heterogenous/cloneable.hpp>
+#include <boost/heterogenous/detail/pointer.hpp>
 
 namespace boost
 {
@@ -15,42 +16,8 @@
         {
                 namespace detail
                 {
- template <class U, class B>
- struct pointer
- {
- typedef U derived_type;
- typedef B base_type;
- typedef cloneable<derived_type, base_type> ptr_type;
- typedef typename cloneable<derived_type, base_type>::this_type cloneable_type;
- typedef typename cloneable_type::abstract_base_type abstract_base_type;
-
- private:
- ptr_type *ptr;
-
- public:
- pointer(U *p = 0) : ptr(dynamic_cast<cloneable_type *>(p))
- {
- }
- abstract_base_type *to_abstract() const
- {
- return ptr;
- }
- base_type *to_base() const
- {
- return ptr;
- }
- cloneable_type *to_cloneable() const
- {
- return ptr;
- }
- derived_type *to_derived() const
- {
- return ptr->cloneable_type::self_ptr;
- }
- };
-
                         template <class U, class Alloc>
- U *allocate_type(Alloc &al)
+ U *allocate(Alloc &al)
                         {
                                 typename Alloc::template rebind<U>::other alloc(al);
                                 return alloc.allocate(1);
@@ -59,7 +26,7 @@
                         // TODO: use variadic template arguments, or BOOST_PP
 
                         template <class U, class Base, class Alloc>
- pointer<U,Base> construct_type(Alloc &al)
+ pointer<U,Base> construct(Alloc &al)
                         {
                                 typename Alloc::template rebind<U>::other alloc(al);
                                 U *ptr = alloc.allocate(1);
@@ -67,27 +34,26 @@
                                 return ptr;
                         }
 
-
                         template <class U, class Base, class Alloc, class A0>
- pointer<U,Base> construct_type(Alloc &al, A0 a0)
+ pointer<U,Base> construct(Alloc &al, A0 a0)
                         {
- U *ptr = allocate_type<U>(al);
+ U *ptr = allocate<U>(al);
                                 new (ptr) U(a0);
                                 return ptr;
                         }
 
                         template <class U, class Base, class Alloc, class A0, class A1>
- pointer<U,Base> construct_type(Alloc &al, A0 a0, A1 a1)
+ pointer<U,Base> construct(Alloc &al, A0 a0, A1 a1)
                         {
- U *ptr = allocate_type<U>(al);
+ U *ptr = allocate<U>(al);
                                 new (ptr) U(a0, a1);
                                 return ptr;
                         }
 
                         template <class U, class Base, class Alloc, class A0, class A1, class A2>
- pointer<U,Base> construct_type(Alloc &al, A0 a0, A1 a1, A2 a2)
+ pointer<U,Base> construct(Alloc &al, A0 a0, A1 a1, A2 a2)
                         {
- U *ptr = allocate_type<U>(al);
+ U *ptr = allocate<U>(al);
                                 new (ptr) U(a0, a1, a2);
                                 return ptr;
                         }
@@ -102,7 +68,7 @@
 
 #include <boost/heterogenous/detail/suffix.hpp>
 
-#endif // BOOST_HETEROGENOUS_DETAIL_CONTAINER_BASE_HPP
+#endif // BOOST_HETEROGENOUS_DETAIL_ALLOCATION_HPP
 
 //EOF
 

Added: sandbox/monotonic/boost/heterogenous/detail/pointer.hpp
==============================================================================
--- (empty file)
+++ sandbox/monotonic/boost/heterogenous/detail/pointer.hpp 2009-06-30 05:14:15 EDT (Tue, 30 Jun 2009)
@@ -0,0 +1,61 @@
+// Copyright (C) 2009 Christian Schladetsch
+//
+// 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)
+
+#ifndef BOOST_HETEROGENOUS_DETAIL_POINTER_HPP
+#define BOOST_HETEROGENOUS_DETAIL_POINTER_HPP
+
+#include <boost/heterogenous/detail/prefix.hpp>
+#include <boost/heterogenous/cloneable.hpp>
+
+namespace boost
+{
+ namespace heterogenous
+ {
+ namespace detail
+ {
+
+ template <class U, class B>
+ struct pointer
+ {
+ typedef U derived_type;
+ typedef B base_type;
+ typedef cloneable<derived_type, base_type> ptr_type;
+ typedef typename cloneable<derived_type, base_type>::this_type cloneable_type;
+ typedef typename cloneable_type::abstract_base_type abstract_base_type;
+
+ private:
+ ptr_type *ptr;
+
+ public:
+ pointer(U *p = 0) : ptr(dynamic_cast<cloneable_type *>(p))
+ {
+ }
+ abstract_base_type *to_abstract() const
+ {
+ return ptr;
+ }
+ base_type *to_base() const
+ {
+ return ptr;
+ }
+ cloneable_type *to_cloneable() const
+ {
+ return ptr;
+ }
+ derived_type *to_derived() const
+ {
+ return ptr->cloneable_type::self_ptr;
+ }
+ };
+
+ } // namespace detail
+
+ } // namespace heterogenous
+
+} // namespace boost
+
+#endif // BOOST_HETEROGENOUS_DETAIL_POINTER_HPP
+
+//EOF

Modified: sandbox/monotonic/boost/heterogenous/map.hpp
==============================================================================
--- sandbox/monotonic/boost/heterogenous/map.hpp (original)
+++ sandbox/monotonic/boost/heterogenous/map.hpp 2009-06-30 05:14:15 EDT (Tue, 30 Jun 2009)
@@ -65,7 +65,7 @@
                                 template <class U>
                                 this_type &value()
                                 {
- U *val = detail::construct_type<U,base_type>(parent->get_allocator()).to_derived();;
+ base_type *val = detail::construct<U,base_type>(parent->get_allocator()).to_base();
                                         parent->insert(std::make_pair(key_instance, val));
                                         return *parent;
                                 }
@@ -74,14 +74,14 @@
                                 template <class U, class A0>
                                 this_type &value(A0 a0)
                                 {
- U *val = detail::construct_type<U,base_type>(parent->get_allocator(), a0).to_derived();;
+ base_type *val = detail::construct<U,base_type>(parent->get_allocator(), a0).to_base();
                                         parent->insert(std::make_pair(key_instance, val));
                                         return *parent;
                                 }
                                 template <class U, class A0, class A1>
                                 this_type &value(A0 a0, A1 a1)
                                 {
- U *val = detail::construct_type<U,base_type>(parent->get_allocator(), a0, a1).to_derived();;
+ base_type *val = detail::construct<U,base_type>(parent->get_allocator(), a0, a1).to_base();
                                         parent->insert(std::make_pair(key_instance, val));
                                         return *parent;
                                 }
@@ -91,7 +91,7 @@
                         template <class U>
                         value_adder key()
                         {
- U *key_instance = detail::construct_type<U,base_type>(get_allocator()).to_derived();
+ base_type *key_instance = detail::construct<U,base_type>(get_allocator()).to_base();
                                 return value_adder(*this, *key_instance);
                         }
 
@@ -99,19 +99,19 @@
                         template <class U, class A0>
                         value_adder key(A0 a0)
                         {
- U *key_instance = detail::construct_type<U,base_type>(get_allocator(), a0).to_derived();
+ base_type *key_instance = detail::construct<U,base_type>(get_allocator(), a0).to_base();
                                 return value_adder(*this, *key_instance);
                         }
                         template <class U, class A0, class A1>
                         value_adder key(A0 a0, A1 a1)
                         {
- U *key_instance = detail::construct_type<U,base_type>(get_allocator(), a0, a1).to_derived();
+ base_type *key_instance = detail::construct<U,base_type>(get_allocator(), a0, a1).to_base();
                                 return value_adder(*this, *key_instance);
                         }
                         template <class U, class A0, class A1, class A2>
                         value_adder key(A0 a0, A1 a1, A2 a2)
                         {
- U *key_instance = detail::construct_type<U,base_type>(get_allocator(), a0, a1, a2).to_derived();
+ base_type *key_instance = detail::construct<U,base_type>(get_allocator(), a0, a1, a2).to_base();
                                 return value_adder(*this, *key_instance);
                         }
 

Modified: sandbox/monotonic/boost/heterogenous/vector.hpp
==============================================================================
--- sandbox/monotonic/boost/heterogenous/vector.hpp (original)
+++ sandbox/monotonic/boost/heterogenous/vector.hpp 2009-06-30 05:14:15 EDT (Tue, 30 Jun 2009)
@@ -178,22 +178,22 @@
                         template <class U>
                         void emplace_back()
                         {
- impl.push_back(detail::construct_type<U,base_type>(get_allocator()).to_abstract());
+ impl.push_back(detail::construct<U,base_type>(get_allocator()).to_abstract());
                         }
                         template <class U, class A0>
                         void emplace_back(A0 a0)
                         {
- impl.push_back(detail::construct_type<U,base_type>(get_allocator(), a0).to_abstract());
+ impl.push_back(detail::construct<U,base_type>(get_allocator(), a0).to_abstract());
                         }
                         template <class U, class A0, class A1>
                         void emplace_back(A0 a0, A1 a1)
                         {
- impl.push_back(detail::construct_type<U,base_type>(get_allocator(), a0,a1).to_abstract());
+ impl.push_back(detail::construct<U,base_type>(get_allocator(), a0,a1).to_abstract());
                         }
                         template <class U, class A0, class A1, class A2>
                         void emplace_back(A0 a0, A1 a1, A2 a2)
                         {
- impl.push_back(detail::construct_type<U,base_type>(get_allocator(), a0,a1,a2).to_abstract());
+ impl.push_back(detail::construct<U,base_type>(get_allocator(), a0,a1,a2).to_abstract());
                         }
 
                         typename implementation::allocator_type get_allocator()

Modified: sandbox/monotonic/libs/monotonic/test/clones/clones.vcproj
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/clones/clones.vcproj (original)
+++ sandbox/monotonic/libs/monotonic/test/clones/clones.vcproj 2009-06-30 05:14:15 EDT (Tue, 30 Jun 2009)
@@ -400,6 +400,10 @@
>
                                         </File>
                                         <File
+ RelativePath="..\..\..\..\boost\heterogenous\detail\pointer.hpp"
+ >
+ </File>
+ <File
                                                 RelativePath="..\..\..\..\boost\heterogenous\detail\prefix.hpp"
>
                                         </File>

Modified: sandbox/monotonic/libs/monotonic/test/clones/tests.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/clones/tests.cpp (original)
+++ sandbox/monotonic/libs/monotonic/test/clones/tests.cpp 2009-06-30 05:14:15 EDT (Tue, 30 Jun 2009)
@@ -147,7 +147,7 @@
 
         test_any();
         test_variant();
-// test_map();
+ test_map();
         test_multiple_inheritance();
 
         // a 'heterogenous' container of objects of any type that derives from common_base


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