id summary reporter owner description type status milestone component version severity resolution keywords cc 4540 fold() instantiates result_of::fold anonymous Douglas Gregor "Hi, this is a complicated one, I'll try my best: there is a problem with fold() and maybe other fusion functions whose result is computed from the result type of user functors. in iteration/detail/fold.hpp, there are two fold()'s, the default one and a specialization for const sequences: {{{ inline typename result_of::fold::type BOOST_FUSION_FOLD_NAME(Seq const& seq,State const& state,F f) }}} I'm not sure why it is there since there isn't any difference to the non-const fold(). but the fact that it is there causes problems when using fold() with a non-const sequence: {{{ fusion::vector vec; fusion::fold(vec,0,F()); }}} even though the sequence is not const, at least MSVC (and I vaguely remember something about that in the C++ standard) instantiates all result types of the function overload set, before the arguments are matched to the non-const fold(). ==> fusion::result_of::fold is instantiated. under normal circumstances this only constitutes an unnecessary instantiation, but when the result type depends on user functors it can cause instantiatiation of undefined types. for example: {{{ struct F{ template struct result; int operator()(int state,int &element) const{ return state; } }; template struct F::result{ typedef int type; }; int main(){ fusion::vector vec; fusion::fold(vec,0,F()); } }}} the result type of F is only defined for argument type ""int &"", which is enough for this fold. but the call to fold() instantiates the ''const'' specialization of fold(), and therefore instantiates result_of::fold, which instantiates the result type of F(State,int const &) ==> compiler error when the following code snippet is added as a workaround, it works: {{{ template struct F::result{ typedef int type; }; }}} bottom line - the const specialization of fold() probably shouldn't be there. " Feature Requests new Boost 1.44.0 result_of Boost Development Trunk Problem mr.chr.schmidt@…