$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r78445 - in sandbox/type_erasure: boost/type_erasure libs/type_erasure/doc libs/type_erasure/example
From: steven_at_[hidden]
Date: 2012-05-12 21:53:53
Author: steven_watanabe
Date: 2012-05-12 21:53:52 EDT (Sat, 12 May 2012)
New Revision: 78445
URL: http://svn.boost.org/trac/boost/changeset/78445
Log:
Doc updates.
Added:
   sandbox/type_erasure/libs/type_erasure/example/associated.cpp   (contents, props changed)
Text files modified: 
   sandbox/type_erasure/boost/type_erasure/callable.hpp        |     3 ++-                                     
   sandbox/type_erasure/boost/type_erasure/deduced.hpp         |     2 +-                                      
   sandbox/type_erasure/boost/type_erasure/same_type.hpp       |     9 +++++++++                               
   sandbox/type_erasure/libs/type_erasure/doc/type_erasure.qbk |    19 ++++++++++++++++++-                     
   sandbox/type_erasure/libs/type_erasure/example/Jamfile.jam  |     1 +                                       
   5 files changed, 31 insertions(+), 3 deletions(-)
Modified: sandbox/type_erasure/boost/type_erasure/callable.hpp
==============================================================================
--- sandbox/type_erasure/boost/type_erasure/callable.hpp	(original)
+++ sandbox/type_erasure/boost/type_erasure/callable.hpp	2012-05-12 21:53:52 EDT (Sat, 12 May 2012)
@@ -34,7 +34,8 @@
 
 /**
  * The @ref callable concept allows an @ref any to hold function objects.
- * @c Sig is interpreted in the same way as for Boost.Function.
+ * @c Sig is interpreted in the same way as for Boost.Function, except
+ * that the arguments and return type are allowed to be placeholders.
  * @c F must be a @ref placeholder.
  *
  * Multiple instances of @ref callable can be used
Modified: sandbox/type_erasure/boost/type_erasure/deduced.hpp
==============================================================================
--- sandbox/type_erasure/boost/type_erasure/deduced.hpp	(original)
+++ sandbox/type_erasure/boost/type_erasure/deduced.hpp	2012-05-12 21:53:52 EDT (Sat, 12 May 2012)
@@ -27,7 +27,7 @@
  * in the arguments of the metafunction and then evaluating it.
  * 
  * When using @ref deduced in a template context, if it is possible for
- * Metafunction to contain no placeholders, use the nested type,
+ * Metafunction to contain no placeholders at all, use the nested type,
  * to automatically evaluate it early as needed.
  */
 template<class Metafunction>
Modified: sandbox/type_erasure/boost/type_erasure/same_type.hpp
==============================================================================
--- sandbox/type_erasure/boost/type_erasure/same_type.hpp	(original)
+++ sandbox/type_erasure/boost/type_erasure/same_type.hpp	2012-05-12 21:53:52 EDT (Sat, 12 May 2012)
@@ -18,6 +18,15 @@
  * A built in concept that indicates that two
  * types are the same.  Either T or U or both
  * can be placeholders.
+ *
+ * \warning Any number of instances of @ref deduced
+ * can be connected with @ref same_type, but there
+ * should be at most one regular placeholder in
+ * the group. same_type<_a, _b> is not allowed.
+ * The reason for this is that the library needs
+ * to normalize all the placeholders, and in this
+ * context there is no way to decide whether to
+ * use @ref _a or @ref _b.
  */
 template<class T, class U>
 struct same_type {};
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-05-12 21:53:52 EDT (Sat, 12 May 2012)
@@ -24,6 +24,7 @@
 [def __binding [classref boost::type_erasure::binding binding]]
 [def __placeholder [classref boost::type_erasure::placeholder placeholder]]
 [def __call [funcref boost::type_erasure::call call]]
+[def __deduced [classref boost::type_erasure::deduced deduced]]
 
 [def __addable [classref boost::type_erasure::addable addable]]
 [def __subtractable [classref boost::type_erasure::subtractable subtractable]]
@@ -56,6 +57,8 @@
 [def __less_than_comparable [classref boost::type_erasure::less_than_comparable less_than_comparable]]
 [def __ostreamable [classref boost::type_erasure::ostreamable ostreamable]]
 [def __istreamable [classref boost::type_erasure::istreamable istreamable]]
+[def __forward_iterator [classref boost::type_erasure::forward_iterator forward_iterator]]
+[def __same_type [classref boost::type_erasure::same_type same_type]]
 
 
 [section:introduction Introduction]
@@ -134,6 +137,11 @@
 [overload]
 [endsect]
 
+[section:overload Associated Types]
+[import ../example/associated.cpp]
+[associated]
+[endsect]
+
 [endsect]
 
 [section:examples Examples]
@@ -204,6 +212,16 @@
     [[`operator[]`][__subscriptable`<R, T, N = std::ptrdiff_t>`][`R` should usually be a reference. `T` can be optionally const qualified.]]
 ]
 
+[table:iterator Iterator Concepts
+    [[concept][notes]]
+    [[__forward_iterator`<T>`][Use __same_type to control the iterator's value type.]]
+]
+
+[table:iterator Special Concepts
+    [[concept][notes]]
+    [[__same_type`<T>`][Indicates that two types are the same.]]
+]
+
 [endsect]
 
 [xinclude reference.xml]
@@ -281,7 +299,6 @@
 * Allow more control over vtable layout.
 * Attempt to reuse sub-tables in conversions.
 * Allow "dynamic_cast".
-* Allow deduction of placeholder bindings.
 * Use C++0x features.  (Rvalue references and
   variadic templates in particular.)
 * Optimize the compile-time cost.
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-05-12 21:53:52 EDT (Sat, 12 May 2012)
@@ -16,5 +16,6 @@
 compile concept_map.cpp ;
 compile compose.cpp ;
 compile overload.cpp ;
+compile associated.cpp ;
 
 run print_sequence.cpp ;
Added: sandbox/type_erasure/libs/type_erasure/example/associated.cpp
==============================================================================
--- (empty file)
+++ sandbox/type_erasure/libs/type_erasure/example/associated.cpp	2012-05-12 21:53:52 EDT (Sat, 12 May 2012)
@@ -0,0 +1,94 @@
+// 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/any_cast.hpp>
+#include <boost/type_erasure/builtin.hpp>
+#include <boost/type_erasure/operators.hpp>
+#include <boost/type_erasure/deduced.hpp>
+#include <boost/type_erasure/same_type.hpp>
+#include <boost/pointee.hpp>
+#include <boost/mpl/vector.hpp>
+#include <iostream>
+
+namespace mpl = boost::mpl;
+using namespace boost::type_erasure;
+
+//[associated1
+/*`
+    Associated types are defined using the __deduced
+    template.  __deduced is just like an ordinary
+    placeholder, except that the type that it binds
+    to is determined by calling a metafunction and
+    does not need to be specified explicitly.
+
+    For example, we can define a concept for
+    holding any iterator, raw pointer, or
+    smart pointer as follows:
+*/
+
+template<class T = _self>
+struct pointer :
+    mpl::vector<
+        copy_constructible<T>,
+        dereferenceable<deduced<boost::pointee<T> >&, T>
+    >
+{
+    typedef deduced<boost::pointee<T> > element_type;
+};
+
+//]
+
+void basic1() {
+    //[associated2
+    /*`
+        Now when we construct `x`, `pointer<>::element_type` is
+        deduced as `boost::pointee<int*>::type` which is `int`.
+    */
+    int i = 10;
+    any<
+        mpl::vector<
+            pointer<>,
+            typeid_<pointer<>::element_type>
+        >
+    > x(&i);
+    int j = boost::type_erasure::any_cast<int>(*x); // j == i
+    //]
+}
+
+void basic2() {
+    //[associated3
+    /*`
+        Referring to the full name of the associated type
+        can be cumbersome when it's used many times.  Also,
+        sometimes we want to require that the associated
+        type be a specific type.  Both of these can be
+        solved using the __same_type concept.  Here we
+        create an any that can hold any pointer whose
+        element type is `int`.
+    */
+    int i = 10;
+    any<
+        mpl::vector<
+            pointer<>,
+            same_type<pointer<>::element_type, int>
+        >
+    > x(&i);
+    std::cout << *x << std::endl; // prints 10
+    //]
+}
+
+//[associated
+//` (For the source of the examples in this section see
+//` [@boost:/libs/type_erasure/example/associated.cpp associated.cpp])
+//` [associated1]
+//` [associated2]
+//` [associated3]
+//]