Re: [Boost-bugs] [Boost C++ Libraries] #4540: fold<Sequence>() instantiates result_of::fold<Sequence const>

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #4540: fold<Sequence>() instantiates result_of::fold<Sequence const>
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-08-17 22:53:07


#4540: fold<Sequence>() instantiates result_of::fold<Sequence const>
--------------------------------------+-------------------------------------
  Reporter: anonymous | Owner: djowel
      Type: Bugs | Status: closed
 Milestone: Boost 1.44.0 | Component: fusion
   Version: Boost Development Trunk | Severity: Problem
Resolution: wontfix | Keywords:
--------------------------------------+-------------------------------------
Changes (by cschmidt):

  * status: new => closed
  * resolution: => wontfix

Comment:

 Replying to [comment:2 anonymous]:
> I see.
> but I guess there is another solution, because the following works:
>
> {{{
>
> struct A{};
>
> template<typename T>
> struct fresult;
>
> template<>
> struct fresult<A>{
> typedef void type;
> };
>
> template<typename T>
> typename fresult<T>::type f(T &){}
> template<typename T>
> typename fresult<T const>::type f(T const &){}
>
> int main(){
> A a;
> f(a);
> }
>
> }}}
>
> the undefined fresult<T const> is not instantiated for the call to the
 non-const overload. I don't know what exactly causes the instantiation of
 result_of::fold<Seq const>, but this suggests there might a solution other
 than removing the const overload.


 That sample compiles fine as SFINAE is taking care of the non-existing
 specialization.
 SFINAE does not help in your fusion usecase, though. There is simply no
 specialization of F::result that matches the template arguments in the
 first place - and that very instantiation is directly referenced by the
 boost::result_of implementation.
 I do not think that this issue can be worked-around.

 Here is a minimal non-fusion testcase.
 {{{
 #include <boost/utility/result_of.hpp>

 struct A{};

 struct F
 {
         template<typename> struct result;
         template<typename Self>struct F::result<Self(A&)>
         {typedef void type;};
 #if 0
         template<typename Self>struct F::result<Self(A const&)>
         {typedef void type;};
 #endif
 };

 template<typename C>
 typename boost::result_of<F(C const&)>::type
 bub(C const&){}

 template<typename C>
 typename boost::result_of<F(C&)>::type
 bub(C&){}

 int main()
 {
         A a;
         bub(a);
 }
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/4540#comment:3>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:04 UTC