Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54517 - in sandbox/monotonic: boost/heterogenous libs/monotonic/test/clones
From: christian.schladetsch_at_[hidden]
Date: 2009-06-30 00:15:16


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

Log:
added heterogenous/forward_declarations.hpp

Added:
   sandbox/monotonic/boost/heterogenous/forward_declarations.hpp (contents, props changed)
Text files modified:
   sandbox/monotonic/boost/heterogenous/abstract_allocator.hpp | 1
   sandbox/monotonic/boost/heterogenous/abstract_base.hpp | 5 +++
   sandbox/monotonic/boost/heterogenous/base.hpp | 7 +++--
   sandbox/monotonic/boost/heterogenous/map.hpp | 5 +--
   sandbox/monotonic/boost/heterogenous/vector.hpp | 2
   sandbox/monotonic/libs/monotonic/test/clones/clones.vcproj | 4 +++
   sandbox/monotonic/libs/monotonic/test/clones/tests.cpp | 47 +++++++++++++++++++++++----------------
   7 files changed, 44 insertions(+), 27 deletions(-)

Modified: sandbox/monotonic/boost/heterogenous/abstract_allocator.hpp
==============================================================================
--- sandbox/monotonic/boost/heterogenous/abstract_allocator.hpp (original)
+++ sandbox/monotonic/boost/heterogenous/abstract_allocator.hpp 2009-06-30 00:15:15 EDT (Tue, 30 Jun 2009)
@@ -7,6 +7,7 @@
 #define BOOST_HETEROGENOUS_ABSTRACT_ALLOCATOR_HPP
 
 #include <boost/heterogenous/detail/prefix.hpp>
+#include <boost/heterogenous/forward_declarations.hpp>
 
 namespace boost
 {

Modified: sandbox/monotonic/boost/heterogenous/abstract_base.hpp
==============================================================================
--- sandbox/monotonic/boost/heterogenous/abstract_base.hpp (original)
+++ sandbox/monotonic/boost/heterogenous/abstract_base.hpp 2009-06-30 00:15:15 EDT (Tue, 30 Jun 2009)
@@ -19,7 +19,7 @@
                 };
 
                 /// common base for all base types for hierachies
- template <class Base = default_base_type>
+ template <class Base>
                 struct abstract_base : Base
                 {
                         typedef Base base_type;
@@ -35,6 +35,9 @@
 
                         virtual this_type *create_new(abstract_allocator &alloc) const = 0;
                         virtual this_type *copy_construct(const base_type &original, abstract_allocator &alloc) const = 0;
+
+ /// optional means to make a clone that does not use copy-construction
+ virtual this_type *clone(const base_type &original, abstract_allocator &alloc) const { return 0; }
                 };
 
         } // namespace heterogenous

Modified: sandbox/monotonic/boost/heterogenous/base.hpp
==============================================================================
--- sandbox/monotonic/boost/heterogenous/base.hpp (original)
+++ sandbox/monotonic/boost/heterogenous/base.hpp 2009-06-30 00:15:15 EDT (Tue, 30 Jun 2009)
@@ -8,14 +8,15 @@
 
 #include <boost/aligned_storage.hpp>
 #include <boost/heterogenous/detail/prefix.hpp>
-#include <boost/heterogenous/common_base.hpp>
+#include <boost/heterogenous/abstract_base.hpp>
 
 namespace boost
 {
         namespace heterogenous
         {
- /// base for the given derived type
- template <class Derived, class Base = default_base_type, class AbstractBase = abstract_base<Base> >
+ /// base for the given derived type, using the given base class
+ /// TODO: rename this - perhaps to 'cloneable'?
+ template <class Derived, class Base, class AbstractBase>
                 struct base : AbstractBase
                 {
                         typedef Derived derived_type;

Added: sandbox/monotonic/boost/heterogenous/forward_declarations.hpp
==============================================================================
--- (empty file)
+++ sandbox/monotonic/boost/heterogenous/forward_declarations.hpp 2009-06-30 00:15:15 EDT (Tue, 30 Jun 2009)
@@ -0,0 +1,51 @@
+// 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_FORWARD_DECLARATIONS_HPP
+#define BOOST_HETEROGENOUS_FORWARD_DECLARATIONS_HPP
+
+#include <functional>
+#include <boost/monotonic/allocator.hpp>
+#include <boost/heterogenous/detail/prefix.hpp>
+
+namespace boost
+{
+ namespace heterogenous
+ {
+ struct abstract_allocator;
+
+ struct default_base_type;
+
+ template <class Base>
+ struct abstract_base;
+
+ template <
+ class Derived
+ , class Base = default_base_type
+ , class AbstractBase = abstract_base<Base> >
+ struct base;
+
+ template <
+ class Base = default_base_type
+ , class Alloc = monotonic::allocator<int>
+ , class AbstractBase = abstract_base<Base> >
+ struct vector;
+
+ template <
+ class Base = default_base_type
+ , class Pred = std::less<Base>
+ , class Alloc = monotonic::allocator<int>
+ , class AbstractBase = abstract_base<Base> >
+ struct map;
+
+ } // namespace heterogenous
+
+} // namespace boost
+
+#include <boost/heterogenous/detail/suffix.hpp>
+
+#endif // BOOST_HETEROGENOUS_FORWARD_DECLARATIONS_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 00:15:15 EDT (Tue, 30 Jun 2009)
@@ -7,7 +7,6 @@
 #define BOOST_HETEROGENOUS_MAP_HPP
 
 #include <boost/ptr_container/ptr_map.hpp>
-#include <boost/monotonic/allocator.hpp>
 #include <boost/foreach.hpp>
 
 #include <boost/heterogenous/detail/prefix.hpp>
@@ -19,7 +18,7 @@
         namespace heterogenous
         {
                 /// a vector of heterogenous objects
- template <class Pred, class Base = common_base, class Alloc = monotonic::allocator<int> >
+ template <class Base, class Pred, class Alloc, class AbstractBase>
                 struct map
                 {
                         typedef typename make_clone_allocator<Alloc>::type allocator_type;
@@ -35,7 +34,7 @@
                         typedef typename implementation::const_iterator const_iterator;
                         typedef typename implementation::key_type key_type;
                         typedef typename implementation::mapped_type mapped_type;
- typedef map<Pred,Base,Alloc> this_type;
+ typedef map<Base, Pred, Alloc, AbstractBase> this_type;
 
                 private:
                         implementation impl;

Modified: sandbox/monotonic/boost/heterogenous/vector.hpp
==============================================================================
--- sandbox/monotonic/boost/heterogenous/vector.hpp (original)
+++ sandbox/monotonic/boost/heterogenous/vector.hpp 2009-06-30 00:15:15 EDT (Tue, 30 Jun 2009)
@@ -20,7 +20,7 @@
         namespace heterogenous
         {
                 /// a vector of heterogenous objects
- template <class Base = default_base_type, class Alloc = monotonic::allocator<int>, class AbstractBase = abstract_base<Base> >
+ template <class Base, class Alloc, class AbstractBase>
                 struct vector
                 {
                         typedef Base base_type;

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 00:15:15 EDT (Tue, 30 Jun 2009)
@@ -373,6 +373,10 @@
>
                                 </File>
                                 <File
+ RelativePath="..\..\..\..\boost\heterogenous\forward_declarations.hpp"
+ >
+ </File>
+ <File
                                         RelativePath="..\..\..\..\boost\heterogenous\make_clone_allocator.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 00:15:15 EDT (Tue, 30 Jun 2009)
@@ -72,28 +72,37 @@
 void test_map();
 
 
- namespace test
+namespace test
+{
+ using namespace heterogenous;
+ struct my_base
         {
- using namespace heterogenous;
- struct my_base
- {
- virtual ~my_base() { }
- };
+ virtual ~my_base() { }
+ };
 
- struct T0 : base<T0, my_base> { };
- struct T1 : base<T1, my_base> { };
+ struct T0 : base<T0, my_base> { };
+ struct T1 : base<T1, my_base> { };
 
- void run()
- {
- typedef heterogenous::vector<my_base> vec;
- vec v0;
- v0.emplace_back<T0>();
- v0.emplace_back<T1>();
- vec v1 = v0;
- my_base &whatever = v1[0];
- assert(v1.ptr_at<T1>(1));
- }
+ void run()
+ {
+ typedef heterogenous::vector<my_base> vec;
+ vec v0;
+ v0.emplace_back<T0>();
+ v0.emplace_back<T1>();
+ vec v1 = v0;
+ my_base &whatever = v1[0];
+ assert(v1.ptr_at<T1>(1));
         }
+}
+
+namespace boost
+{
+ namespace heterogenous
+ {
+ //template <class T, template <class> class Base = base, class AbstractBase = abstract_base>
+ //struct adaptor :
+ }
+}
 
 int main()
 {
@@ -226,7 +235,7 @@
 
 void test_map()
 {
- heterogenous::map<my_less, my_base2> map;
+ heterogenous::map<my_base2,my_less> map;
 
         map .key<T0>().value<T1>()
                 .key<T2>().value<T3>()


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