Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69206 - sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch
From: cppljevans_at_[hidden]
Date: 2011-02-23 08:25:45


Author: cppljevans
Date: 2011-02-23 08:25:44 EST (Wed, 23 Feb 2011)
New Revision: 69206
URL: http://svn.boost.org/trac/boost/changeset/69206

Log:
WHAT:
  Added host_abstract metafunction to do reverse of hosts_concrete.
WHY:
  solve problem when concrete val or ref passed to functor. In this
  case, hosts_concrete<HostConcrete>::type is undefined, resulting in
  compile-time error:

http://groups.google.com/group/comp.lang.c++/msg/824f1eac9a49d40d

WHYNOT:
  1) requires defining specialization of host_abstract for each
     derived class.
  2) causes conversion of a concrete class back to its abstract
     class and then extra virtual function calls to then
     convert back to concrete class.
-

Text files modified:
   sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reifier_visitor.hpp | 24 ++++++++++++++++++++++--
   1 files changed, 22 insertions(+), 2 deletions(-)

Modified: sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reifier_visitor.hpp
==============================================================================
--- sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reifier_visitor.hpp (original)
+++ sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reifier_visitor.hpp 2011-02-23 08:25:44 EST (Wed, 23 Feb 2011)
@@ -195,6 +195,24 @@
    */
 ;
   template
+ < typename HostConcrete
+ >
+struct host_abstract
+ /**@brief
+ * Metafunction returning Abstract class
+ * of which HostConcrete is a member.
+ * IOW, does inverse of hosts_concrete.
+ */
+{
+ typedef
+ HostConcrete
+ type
+ //By default, HostConcrete is member
+ //of a type hierarchy starting at
+ //HostConcrete.
+ ;
+};
+ template
   < typename ReifyApply
   , typename ArgsConcreteAbstract
>
@@ -246,8 +264,10 @@
>
>
   , typename hosts_concrete
- < typename remove_cv
- < HeadAbstract
+ < typename host_abstract
+ < typename remove_cv
+ < HeadAbstract
+ >::type
>::type
>::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