$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r79728 - in sandbox/type_erasure/libs/type_erasure: doc example
From: steven_at_[hidden]
Date: 2012-07-24 18:07:54
Author: steven_watanabe
Date: 2012-07-24 18:07:53 EDT (Tue, 24 Jul 2012)
New Revision: 79728
URL: http://svn.boost.org/trac/boost/changeset/79728
Log:
Add example of conversion.
Added:
   sandbox/type_erasure/libs/type_erasure/example/convert.cpp   (contents, props changed)
Text files modified: 
   sandbox/type_erasure/libs/type_erasure/doc/type_erasure.qbk |     5 +++++                                   
   sandbox/type_erasure/libs/type_erasure/example/Jamfile.jam  |     1 +                                       
   2 files changed, 6 insertions(+), 0 deletions(-)
Modified: sandbox/type_erasure/libs/type_erasure/doc/type_erasure.qbk
==============================================================================
--- sandbox/type_erasure/libs/type_erasure/doc/type_erasure.qbk	(original)
+++ sandbox/type_erasure/libs/type_erasure/doc/type_erasure.qbk	2012-07-24 18:07:53 EDT (Tue, 24 Jul 2012)
@@ -113,6 +113,11 @@
 [multi]
 [endsect]
 
+[section:convert Conversions]
+[import ../example/convert.cpp]
+[convert]
+[endsect]
+
 [section:references Using References]
 [import ../example/references.cpp]
 [references]
Modified: sandbox/type_erasure/libs/type_erasure/example/Jamfile.jam
==============================================================================
--- sandbox/type_erasure/libs/type_erasure/example/Jamfile.jam	(original)
+++ sandbox/type_erasure/libs/type_erasure/example/Jamfile.jam	2012-07-24 18:07:53 EDT (Tue, 24 Jul 2012)
@@ -10,6 +10,7 @@
 
 compile basic.cpp ;
 compile multi.cpp ;
+compile convert.cpp ;
 compile references.cpp ;
 compile custom.cpp ;
 compile construction.cpp ;
Added: sandbox/type_erasure/libs/type_erasure/example/convert.cpp
==============================================================================
--- (empty file)
+++ sandbox/type_erasure/libs/type_erasure/example/convert.cpp	2012-07-24 18:07:53 EDT (Tue, 24 Jul 2012)
@@ -0,0 +1,58 @@
+// Boost.TypeErasure library
+//
+// Copyright 2012 Steven Watanabe
+//
+// 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)
+//
+// $Id$
+
+#include <boost/type_erasure/any.hpp>
+#include <boost/type_erasure/builtin.hpp>
+#include <boost/type_erasure/operators.hpp>
+
+namespace mpl = boost::mpl;
+using namespace boost::type_erasure;
+
+void convert1() {
+//[convert1
+    /*`
+        An __any can be converted to another __any
+        as long as the conversion is an "upcast."
+    */
+
+    typedef any<
+        mpl::vector<
+            copy_constructible<>,
+            typeid_<>,
+            ostreamable<>
+        >
+    > any_printable;
+    typedef any<
+        mpl::vector<
+            copy_constructible<>,
+            typeid_<>
+        >
+    > common_any;
+    any_printable x(10);
+    common_any y(x);
+
+    /*`
+        This conversion is okay because the requirements of `common_any`
+        are a subset of the requirements of `any_printable`.  Conversion
+        in the other direction is illegal.
+
+        ``
+            common_any x(10);
+            any_printable y(x); // error
+        ``
+    */
+//]
+}
+
+//[convert
+//` (For the source of the examples in this section see
+//` [@boost:/libs/type_erasure/example/convert.cpp convert.cpp])
+//` [convert1]
+//]