$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Daniel Wallin (dalwan01_at_[hidden])
Date: 2005-05-09 05:01:24
David Abrahams wrote:
[...]
> The question is, what should we do about this?  It turns out to be
> surprisingly hard to write the declarations of these temporary
> variables so they work in all cases.  For example, v had to be a
> const& because in one case index_result<...>::type turned out to be
> 
>   char const[4]
> 
> and when the default is used, it's 
> 
>   double 
> 
> with p[value || ...] returning a double rvalue (by value).
> 
> Thoughts?
Make the user add reference to the Default type instead of
index_result<>::type?
   template<class Params>
   void f_impl(const Params& p)
   {
       typename boost::parameter::index_result<
         Params, struct name_>::type n = p[name];
       typename boost::parameter::index_result<
         Params, struct value_, double
       >::type v = p[value || boost::bind(&value_default) ];
       typename boost::parameter::index_result<
         Params, struct index_, int
       >::type i = p[index | 999];
       g(n,v,i);
   }
So index_result<Params, Keyword, Default>::type would be either
Params[Keyword]::type& or Default.
And maybe add another metafunction that returns Params[Keyword]::type
without a reference.
-- Daniel Wallin