Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54474 - sandbox/monotonic/boost/heterogenous
From: christian.schladetsch_at_[hidden]
Date: 2009-06-28 17:32:58


Author: cschladetsch
Date: 2009-06-28 17:32:57 EDT (Sun, 28 Jun 2009)
New Revision: 54474
URL: http://svn.boost.org/trac/boost/changeset/54474

Log:
comment changes

Text files modified:
   sandbox/monotonic/boost/heterogenous/vector.hpp | 59 +++++++++++++++++++++++----------------
   1 files changed, 34 insertions(+), 25 deletions(-)

Modified: sandbox/monotonic/boost/heterogenous/vector.hpp
==============================================================================
--- sandbox/monotonic/boost/heterogenous/vector.hpp (original)
+++ sandbox/monotonic/boost/heterogenous/vector.hpp 2009-06-28 17:32:57 EDT (Sun, 28 Jun 2009)
@@ -48,10 +48,40 @@
                         vector(size_t reserved);
                         */
 
+ template <class Ty, class Fun>
+ Fun foreach(Fun fun)
+ {
+ BOOST_FOREACH(common_base &b, *this)
+ {
+ if (Ty *ptr = dynamic_cast<Ty *>(&b))
+ {
+ fun(*ptr);
+ }
+ }
+ return fun;
+ }
+
+ template <class Ty, class Fun>
+ Fun foreach(Fun fun) const
+ {
+ BOOST_FOREACH(const common_base &base, *this)
+ {
+ if (Ty *ptr = dynamic_cast<Ty *>(&base))
+ {
+ fun(*ptr);
+ }
+ }
+ return fun;
+ }
+
                         size_t size() const
                         {
                                 return impl.size();
                         }
+ bool empty() const
+ {
+ return impl.empty();
+ }
 
                         iterator begin()
                         {
@@ -103,11 +133,13 @@
                         {
                                 return impl[n];
                         }
+
                         template <class Other>
                         bool is_type_at(size_t n) const
                         {
                                 return ptr_at<Other>(n) != 0;
                         }
+
                         template <class Other>
                         Other &ref_at(size_t n)
                         {
@@ -124,6 +156,7 @@
                                         throw std::bad_cast();
                                 return *ptr;
                         }
+
                         template <class Other>
                         Other *ptr_at(size_t n)
                         {
@@ -135,6 +168,7 @@
                                 return dynamic_cast<const Other *>(&at(n));
                         }
 
+ // TODO: use variadic arguments or BOOST_PP to pass ctor args
                         template <class U>
                         void push_back()
                         {
@@ -168,31 +202,6 @@
                                 return impl.get_allocator();
                         }
 
- template <class Ty, class Fun>
- Fun foreach(Fun fun)
- {
- BOOST_FOREACH(common_base &b, *this)
- {
- if (Ty *ptr = dynamic_cast<Ty *>(&b))
- {
- fun(*ptr);
- }
- }
- return fun;
- }
-
- template <class Ty, class Fun>
- Fun foreach(Fun fun) const
- {
- BOOST_FOREACH(const common_base &base, *this)
- {
- if (Ty *ptr = dynamic_cast<Ty *>(&base))
- {
- fun(*ptr);
- }
- }
- return fun;
- }
                 private:
                         template <class U>
                         U *allocate_type()


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