
On 6/29/2012 7:51 PM, Eric Niebler wrote:
On 6/29/2012 5:36 AM, Sergiu Dotenco wrote:
Boost.Foreach causes compilation errors when using Microsoft Visual Studio 10. The issue can be resolved by adding
#include <boost/utility/enable_if.hpp>
to boost/for_each.hpp.
I'm not seeing that. The following program compiles cleanly for me on VC10.
#include <boost/foreach.hpp> int main() {}
The only place enable_if is used in foreach.hpp is conditionally guarded by a macro, and #include <boost/utility/enable_if.hpp> is conditionally guarded by the same macro.
Can you send a minimal program that demonstrates the error?
My apologies, Eric. The compilation errors are not caused by Boost.Foreach. I should have been more careful while summarizing the issue details. The problem seems to be in boost/range/algorithm/for_each.hpp. If I try to compile the following snippet using VC10, #include <boost/range/algorithm/for_each.hpp> void foo(int) { } int main() { int a[] = { 1, 2, 3 }; boost::for_each(a, foo); } the compiler outputs boost_1_50_0\boost\range\algorithm\for_each.hpp(34): error C2143: syntax error : missing ',' before '<' boost_1_50_0\boost\range\algorithm\for_each.hpp(34): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int boost_1_50_0\boost\range\algorithm\for_each.hpp(52): error C2143: syntax error : missing ',' before '<' boost_1_50_0\boost\range\algorithm\for_each.hpp(52): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int boost_1_50_0\boost\range\algorithm\for_each.hpp(58): error C2995: 'UnaryFunction boost::range::for_each_detail::for_each_impl(Iterator,Iterator,UnaryFunction,int)' : function template has already been defined boost_1_50_0\boost\range\algorithm\for_each.hpp(33) : see declaration of 'boost::range::for_each_detail::for_each_impl' due to the missing #include <boost/utility/enable_if.hpp> in boost/range/algorithm/for_each.hpp.