[Boost-bugs] [Boost C++ Libraries] #5490: Fusion fails to insulate user-supplied template parameters from unintentional MPL placeholder substitution (?)

Subject: [Boost-bugs] [Boost C++ Libraries] #5490: Fusion fails to insulate user-supplied template parameters from unintentional MPL placeholder substitution (?)
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-04-19 23:49:11


#5490: Fusion fails to insulate user-supplied template parameters from
unintentional MPL placeholder substitution (?)
-----------------------------------------------------------+----------------
 Reporter: Jeffrey Hellrung <jeffrey.hellrung@…> | Owner: djowel
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: fusion
  Version: Boost 1.47.0 | Severity: Problem
 Keywords: fusion, mpl, placeholder, substitution |
-----------------------------------------------------------+----------------
 The code below fails on MSVC9 with Boost 1.43.0, but recent developers'
 list activity {{{[1]}}} suggests this is still broken in Boost 1.46.1.
 And, to emphasize, I believe it *should* compile, but I could be wrong
 there!

 {{{
 #include <iostream>

 #include <boost/fusion/algorithm/transformation/transform.hpp>
 #include <boost/fusion/container/vector/vector10.hpp>
 #include <boost/fusion/sequence/io/out.hpp>
 #include <boost/mpl/quote.hpp>
 #include <boost/mpl/placeholders.hpp>
 #include <boost/type_traits/is_integral.hpp>

 template< class >
 struct foo
 {
     typedef int result_type;
     template< class T >
     int operator()(const T&) const
     { return 0; }
 };


 int main()
 {
     boost::fusion::vector1< int > v;
     typedef boost::is_integral< boost::mpl::_1 > mpl_type; // 1
     //typedef boost::mpl::quote1< boost::is_integral > mpl_type; // 2
     std::cout << boost::fusion::transform(v, foo< mpl_type >());

     return 0;
 }
 }}}

 A workaround is to use "// 2" rather than "// 1".

 I believe the proper fix is to insulate any user-supplied template
 parameters from unintential Boost.MPL placeholder substitution within the
 implementation of boost::fusion::transform and/or
 boost::fusion::transform_view, but I haven't looked into where exactly
 this should occur or how widespread this is.

 The existence of a workaround together with the probable rarity of the
 situation likely makes this a low-priority bug, but it is a subtle problem
 once you run into it.

 {{{[1]}}} http://thread.gmane.org/gmane.comp.lib.boost.devel/218162

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5490>
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:06 UTC