|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r78404 - sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch
From: cppljevans_at_[hidden]
Date: 2012-05-10 11:27:59
Author: cppljevans
Date: 2012-05-10 11:27:56 EDT (Thu, 10 May 2012)
New Revision: 78404
URL: http://svn.boost.org/trac/boost/changeset/78404
Log:
Replaced reifier_{switch,funvec} with revised
reifier_indexed_base(renamed to reifier_indexed)
and new template, dispatch_indexes, in
functor_indexed.hpp.
Added:
sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reifier_indexed.hpp
- copied, changed from r78360, /sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reifier_indexed_base.hpp
Removed:
sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reifier_funvec.hpp
sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reifier_indexed_base.hpp
sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reifier_switch.hpp
Text files modified:
sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reifier_base.hpp | 27 +++++++++++------------
sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reifier_indexed.hpp | 46 ++++++++++++++++++++++++---------------
sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reify_apply.hpp | 2
3 files changed, 42 insertions(+), 33 deletions(-)
Modified: sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reifier_base.hpp
==============================================================================
--- sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reifier_base.hpp (original)
+++ sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reifier_base.hpp 2012-05-10 11:27:56 EDT (Thu, 10 May 2012)
@@ -41,17 +41,9 @@
>
>
/**@brief
- * Uses switch statment (in functor_indexed::apply)
- * to convert HeadAbstract, which should be of type,
- * a composite_storage<one_of_maybe, _, TailConcrete...>,
- * to one of the TailConcretes, and then call
- * a ReifyApply with the converted ptrs_target_source.
+ * See push_back_concrete member template function.
*/
{
- typedef
- HeadAbstract
- head_abstract_t
- ;
ReifyApply const&
my_reify
;
@@ -60,7 +52,7 @@
< mpl::package
< HeadConcrete...
>
- , head_abstract_t
+ , HeadAbstract
, TailAbstract...
>
now_tar_src_type
@@ -76,8 +68,16 @@
, my_tar_src(a_ptrs_tar_src)
{
}
+ typedef
+ HeadAbstract
+ head_abstract_t
+ ;
head_abstract_t&
head_abstract()const
+ /**@brief
+ * The next abstract type to be converted
+ * to it's concrete type.
+ */
{
return my_tar_src->template project
< sizeof...(HeadConcrete)
@@ -95,10 +95,9 @@
( TailConcrete& a_tail_concrete
)const
/**@brief
- * Casts the head abstract value in the ptrs_target_source
- * into a TailConcrete value, and
- * then recurses on remaining abstract args
- * by calling on my_reify.
+ * Casts the HeadAbstract* in the ptrs_target_source
+ * into a TailConcrete*, and then recurses on
+ * remaining abstract args, TailAbstract..., using my_reify.
*/
{
typedef
Deleted: sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reifier_funvec.hpp
==============================================================================
--- sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reifier_funvec.hpp 2012-05-10 11:27:56 EDT (Thu, 10 May 2012)
+++ (empty file)
@@ -1,170 +0,0 @@
-//
-#ifndef BOOST_COMPOSITE_STORAGE_PACK_MULTIPLE_DISPATCH_REIFIER_FUNVEC_HPP_INCLUDED
-#define BOOST_COMPOSITE_STORAGE_PACK_MULTIPLE_DISPATCH_REIFIER_FUNVEC_HPP_INCLUDED
-// (C) Copyright Larry Evans 2010.
-//
-// Permission to copy, use, modify, sell and distribute this software
-// is granted provided this copyright notice appears in all copies
-// This software is provided "as is" without express or implied
-// warranty, and with no claim as to its suitability for any purpose.
-//
-#include <boost/composite_storage/pack/multiple_dispatch/reifier_indexed_base.hpp>
-
-namespace boost
-{
-namespace composite_storage
-{
-namespace pack
-{
-namespace multiple_dispatch
-{
-
- template
- < typename ReifyApply
- , typename ArgsConcreteAbstract
- >
-struct reifier_funvec
-: reifier_indexed_base
- < ReifyApply
- , ArgsConcreteAbstract
- >
- /**@brief
- * Uses vector of functions (see static our_vec() below)
- * to convert "abstract" head of an ArgsConcreteAbstract to
- * its "concrete" counterpart, and then call
- * a ReifyApply with the converted ArgsConcreteAbstract.
- */
-{
- typedef
- reifier_indexed_base
- < ReifyApply
- , ArgsConcreteAbstract
- >
- super_t
- ;
- reifier_funvec
- ( ReifyApply const& a_reify
- , ArgsConcreteAbstract* a_ptrs_tar_src
- )
- : super_t
- ( a_reify
- , a_ptrs_tar_src
- )
- {
- }
- typedef
- typename ReifyApply::result_type
- result_type
- ;
- typedef
- reifier_funvec
- < ReifyApply
- , ArgsConcreteAbstract
- >
- this_type
- ;
- template<class Case>
- struct fun_case
- {
- static
- result_type
- _(this_type const& f)
- {
- Case arg;
- return f(arg);
- }
- };
- typedef
- typename super_t::cases
- cases
- ;
- typedef
- typename super_t::case_type
- case_type
- ;
- struct fun_vec
- {
- typedef
- result_type
- (*
- fun_type
- )(this_type const&)
- ;
- static
- unsigned const
- vec_size
- = boost::mpl::size<cases>::type::value
- ;
- typedef
- fun_type
- vec_type
- [ vec_size
- ]
- ;
- static
- unsigned
- case_index
- ( case_type index
- )
- {
- return index-cases::start::value;
- }
- struct fill_vec
- {
- vec_type&
- my_vec
- ;
- fill_vec(vec_type& a_vec)
- : my_vec(a_vec)
- {}
- template
- < typename Case
- >
- void
- operator()(Case)
- {
- unsigned const index=case_index(Case::value);
- my_vec[index]=fun_case<Case>::_;
- }
- };
- vec_type
- my_vec
- ;
- fun_vec(void)
- {
- boost::mpl::for_each<cases>(fill_vec(my_vec));
- }
- fun_type
- operator[](case_type i)const
- {
- unsigned const index=case_index(i);
- return my_vec[index];
- }
-
- };
- static
- fun_vec const&
- our_vec(void)
- {
- static fun_vec const a_vec;
- return a_vec;
- }
- result_type
- reify_rest
- ( void
- )const
- /**@brief
- * Indirectly, calls this->super_t::operator()( mpl::integral_c<case_type,CaseValue> index)
- * where CaseValue == head_abstract().which().
- */
- {
- return our_vec()[this->head_abstract().which()](*this);
- }
-};
-
-}//exit namespace multiple_dispatch
-}//exit namespace pack
-
-}//exit composite_storage namespace
-}//exit boost namespace
-#endif
Copied: sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reifier_indexed.hpp (from r78360, /sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reifier_indexed_base.hpp)
==============================================================================
--- /sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reifier_indexed_base.hpp (original)
+++ sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reifier_indexed.hpp 2012-05-10 11:27:56 EDT (Thu, 10 May 2012)
@@ -1,6 +1,6 @@
//
-#ifndef BOOST_COMPOSITE_STORAGE_PACK_MULTIPLE_DISPATCH_REIFIER_INDEXED_BASE_HPP_INCLUDED
-#define BOOST_COMPOSITE_STORAGE_PACK_MULTIPLE_DISPATCH_REIFIER_INDEXED_BASE_HPP_INCLUDED
+#ifndef BOOST_COMPOSITE_STORAGE_PACK_MULTIPLE_DISPATCH_REIFIER_INDEXED_HPP_INCLUDED
+#define BOOST_COMPOSITE_STORAGE_PACK_MULTIPLE_DISPATCH_REIFIER_INDEXED_HPP_INCLUDED
// (C) Copyright Larry Evans 2010.
//
// Permission to copy, use, modify, sell and distribute this software
@@ -24,7 +24,7 @@
< typename ReifyApply
, typename ArgsConcreteAbstract
>
-struct reifier_indexed_base
+struct reifier_indexed
: reifier_base
< ReifyApply
, ArgsConcreteAbstract
@@ -42,25 +42,21 @@
head_abstract_t
;
typedef
- typename functor_indexed::layout_visitor
+ typename functor_indexed::layout_domain
< head_abstract_t
, typename head_abstract_t::index_undefined
>
- layout_visitor
+ layout_domain
;
typedef
- typename layout_visitor::case_type
- case_type
+ typename layout_domain::index_type
+ index_type
;
typedef
- typename layout_visitor::cases
- cases
+ typename layout_domain::indexes
+ indexes
;
- typedef
- typename head_abstract_t::index_type
- index_type
- ;
- reifier_indexed_base
+ reifier_indexed
( ReifyApply const& a_reify
, ArgsConcreteAbstract* a_ptrs_tar_src
)
@@ -75,20 +71,20 @@
result_type
;
template
- < case_type CaseValue
+ < index_type IndexValue
>
result_type
operator()
- ( mpl::integral_c<case_type,CaseValue> index
+ ( mpl::integral_c<index_type,IndexValue> index
)const
/**@brief
* "Reifies" the head_abstract() into
- * the type indicated by the tag, CaseValue.
+ * the type indicated by the tag, IndexValue.
* Then calls this->push_back_concrete.
*/
{
index_type const
- index_concrete=index_type(CaseValue);
+ index_concrete=index_type(IndexValue);
typename super_t::head_abstract_t&
my_head_abstract=this->head_abstract();
typedef
@@ -98,6 +94,20 @@
return this->push_back_concrete(a_tail_concrete);
}
+ result_type
+ reify_rest
+ ( void
+ )const
+ /**@brief
+ * Indirectly, calls this->operator()( mpl::integral_c<index_type,IndexValue> index)
+ * where IndexValue == head_abstract().which().
+ */
+ {
+ return functor_indexed::apply
+ ( *this
+ , this->head_abstract().which()
+ );
+ }
};
}//exit namespace multiple_dispatch
Deleted: sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reifier_indexed_base.hpp
==============================================================================
--- sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reifier_indexed_base.hpp 2012-05-10 11:27:56 EDT (Thu, 10 May 2012)
+++ (empty file)
@@ -1,108 +0,0 @@
-//
-#ifndef BOOST_COMPOSITE_STORAGE_PACK_MULTIPLE_DISPATCH_REIFIER_INDEXED_BASE_HPP_INCLUDED
-#define BOOST_COMPOSITE_STORAGE_PACK_MULTIPLE_DISPATCH_REIFIER_INDEXED_BASE_HPP_INCLUDED
-// (C) Copyright Larry Evans 2010.
-//
-// Permission to copy, use, modify, sell and distribute this software
-// is granted provided this copyright notice appears in all copies.
-// This software is provided "as is" without express or implied
-// warranty, and with no claim as to its suitability for any purpose.
-//
-#include <boost/composite_storage/pack/multiple_dispatch/reifier_base.hpp>
-#include <boost/composite_storage/functor_indexed.hpp>
-
-namespace boost
-{
-namespace composite_storage
-{
-namespace pack
-{
-namespace multiple_dispatch
-{
-
- template
- < typename ReifyApply
- , typename ArgsConcreteAbstract
- >
-struct reifier_indexed_base
-: reifier_base
- < ReifyApply
- , ArgsConcreteAbstract
- >
-{
- typedef
- reifier_base
- < ReifyApply
- , ArgsConcreteAbstract
- >
- super_t
- ;
- typedef
- typename super_t::head_abstract_t
- head_abstract_t
- ;
- typedef
- typename functor_indexed::layout_visitor
- < head_abstract_t
- , typename head_abstract_t::index_undefined
- >
- layout_visitor
- ;
- typedef
- typename layout_visitor::case_type
- case_type
- ;
- typedef
- typename layout_visitor::cases
- cases
- ;
- typedef
- typename head_abstract_t::index_type
- index_type
- ;
- reifier_indexed_base
- ( ReifyApply const& a_reify
- , ArgsConcreteAbstract* a_ptrs_tar_src
- )
- : super_t
- ( a_reify
- , a_ptrs_tar_src
- )
- {
- }
- typedef
- typename ReifyApply::result_type
- result_type
- ;
- template
- < case_type CaseValue
- >
- result_type
- operator()
- ( mpl::integral_c<case_type,CaseValue> index
- )const
- /**@brief
- * "Reifies" the head_abstract() into
- * the type indicated by the tag, CaseValue.
- * Then calls this->push_back_concrete.
- */
- {
- index_type const
- index_concrete=index_type(CaseValue);
- typename super_t::head_abstract_t&
- my_head_abstract=this->head_abstract();
- typedef
- decltype(my_head_abstract.template project<index_concrete>())
- tail_type;
- tail_type& a_tail_concrete=my_head_abstract.template project<index_concrete>();
- return this->push_back_concrete(a_tail_concrete);
- }
-
-};
-
-}//exit namespace multiple_dispatch
-}//exit namespace pack
-
-}//exit composite_storage namespace
-}//exit boost namespace
-#endif
Deleted: sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reifier_switch.hpp
==============================================================================
--- sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reifier_switch.hpp 2012-05-10 11:27:56 EDT (Thu, 10 May 2012)
+++ (empty file)
@@ -1,80 +0,0 @@
-//
-#ifndef BOOST_COMPOSITE_STORAGE_PACK_MULTIPLE_DISPATCH_REIFIER_SWITCH_HPP_INCLUDED
-#define BOOST_COMPOSITE_STORAGE_PACK_MULTIPLE_DISPATCH_REIFIER_SWITCH_HPP_INCLUDED
-// (C) Copyright Larry Evans 2010.
-//
-// Permission to copy, use, modify, sell and distribute this software
-// is granted provided this copyright notice appears in all copies.
-// This software is provided "as is" without express or implied
-// warranty, and with no claim as to its suitability for any purpose.
-//
-#include <boost/composite_storage/pack/multiple_dispatch/reifier_indexed_base.hpp>
-
-namespace boost
-{
-namespace composite_storage
-{
-namespace pack
-{
-namespace multiple_dispatch
-{
-
- template
- < typename ReifyApply
- , typename ArgsConcreteAbstract
- >
-struct reifier_switch
-: reifier_indexed_base
- < ReifyApply
- , ArgsConcreteAbstract
- >
- /**@brief
- * Uses switch statment (in functor_indexed::apply)
- * to convert "abstract" head of an ArgsConcreteAbstract to
- * its "concrete" counterpart, and then call
- * a ReifyApply with the converted ArgsConcreteAbstract.
- */
-{
- typedef
- reifier_indexed_base
- < ReifyApply
- , ArgsConcreteAbstract
- >
- super_t
- ;
- reifier_switch
- ( ReifyApply const& a_reify
- , ArgsConcreteAbstract* a_ptrs_tar_src
- )
- : super_t
- ( a_reify
- , a_ptrs_tar_src
- )
- {
- }
- typedef
- typename ReifyApply::result_type
- result_type
- ;
- result_type
- reify_rest
- ( void
- )const
- /**@brief
- * Indirectly, calls this->super_t::operator()( mpl::integral_c<case_type,CaseValue> index)
- * where CaseValue == head_abstract().which().
- */
- {
- return functor_indexed::apply
- ( *this
- , this->head_abstract().which()
- );
- }
-};
-
-}//exit namespace multiple_dispatch
-}//exit namespace pack
-
-}//exit composite_storage namespace
-}//exit boost namespace
-#endif
Modified: sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reify_apply.hpp
==============================================================================
--- sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reify_apply.hpp (original)
+++ sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reify_apply.hpp 2012-05-10 11:27:56 EDT (Thu, 10 May 2012)
@@ -84,7 +84,7 @@
* When there are no more abstract arguments
* ( presumably after a number of calls to
* the previous operator()(...) member function.
- * ) apply my_functor to *tar_src_p nd return result.
+ * ) apply my_functor to *tar_src_p and return result.
*/
{
#ifdef MULTIPLE_DISPATCH_DEBUG
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