Boost logo

Boost-Commit :

From: jared_at_[hidden]
Date: 2007-05-24 23:17:02


Author: jared
Date: 2007-05-24 23:17:02 EDT (Thu, 24 May 2007)
New Revision: 4237
URL: http://svn.boost.org/trac/boost/changeset/4237

Log:
Add a printer that dereferences pointers (recursively) so that they print what is actually being pointed to.

Text files modified:
   sandbox/explore/boost/explore/explore.hpp | 27 +++++++++++++++++++++------
   1 files changed, 21 insertions(+), 6 deletions(-)

Modified: sandbox/explore/boost/explore/explore.hpp
==============================================================================
--- sandbox/explore/boost/explore/explore.hpp (original)
+++ sandbox/explore/boost/explore/explore.hpp 2007-05-24 23:17:02 EDT (Thu, 24 May 2007)
@@ -16,7 +16,7 @@
 
 #include <iostream>
 #include <map>
-#include <iterator>
+#include <iterator>
 #include <boost/mpl/bool.hpp>
 #include <boost/mpl/if.hpp>
 #include <boost/mpl/eval_if.hpp>
@@ -27,8 +27,8 @@
 #include <boost/mpl/push_front.hpp>
 #include <boost/mpl/pop_front.hpp>
 #include <boost/mpl/identity.hpp>
-#include <boost/utility/enable_if.hpp>
-#include <boost/foreach.hpp>
+#include <boost/utility/enable_if.hpp>
+#include <boost/foreach.hpp>
 #include <boost/range/iterator.hpp>
 
 namespace explore {
@@ -292,6 +292,18 @@
         */
 
         };
+
+ struct pointer_printer
+ {
+ template< typename format_type,
+ typename container_policy_type,
+ typename item_type
+ >
+ static std::ostream &print_item( const item_type *item, std::ostream &stream )
+ {
+ return print(*item, stream, format_type(), container_policy_type());
+ }
+ };
 
         struct item_printer
         {
@@ -316,9 +328,12 @@
         {
                 typedef typename eval_if<
                         typename container_policy_type:: template print_as_container< item_type>::type,
- identity< container_printer>,
- identity< item_printer>
- >::type printer_type;
+ identity<container_printer>,
+ eval_if<
+ typename boost::is_pointer<item_type>::type,
+ identity<pointer_printer>,
+ identity<item_printer>
+ > >::type printer_type;
 
                 
         return printer_type::template print_item< format_type, container_policy_type>( item, stream);


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