Consider this (working) code using Boost.FileSystem:
fs::directory_iterator di(dir);
fs::directory_iterator end;
while (di != end) {
if (is_directory(*di)) cout << "D\n";
else cout << "~D\n";
++di;
}
This looks like it should be lambda-able. Here's my attempt:
for_each(fs::directory_iterator(dir), fs::directory_iterator(),
if_then_else(bind(&fs::is_directory, _1),
cout << "D\n",
cout << "~D\n"));
VC7.1 doesn't like this -- the diagnostics are below. Any idea how I can make
this work?
Thanks,
Scott
fs.cpp(39) : error C2784: 'const
boost::lambda::lambda_functor>>
boost::lambda::if_then_else
(const boost::lambda::lambda_functor<Arg1> &,const
boost::lambda::lambda_functor<Arg2> &,const boost::lambda::lambda_functor<Arg3>
&)' : could no
t deduce template argument for 'const boost::lambda::lambda_functor<T2> &' from
'std::basic_ostream<_Elem,_Traits>'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
D:\C++\Boost\Current\boost\lambda\if.hpp(100) : see declaration of
'boost::lambda::if_then_else'
fs.cpp(39) : error C2784: 'const
boost::lambda::lambda_functor>>
boost::lambda::if_then_else
(const boost::lambda::lambda_functor<Arg1> &,const
boost::lambda::lambda_functor<Arg2> &,const boost::lambda::lambda_functor<Arg3>
&)' : could no
t deduce template argument for 'const boost::lambda::lambda_functor<T2> &' from
'std::basic_ostream<_Elem,_Traits>'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
D:\C++\Boost\Current\boost\lambda\if.hpp(100) : see declaration of
'boost::lambda::if_then_else'
fs.cpp(39) : error C2784: 'const
boost::lambda::lambda_functor>>
boost::lambda::if_then_else
(const boost::lambda::lambda_functor<Arg1> &,const
boost::lambda::lambda_functor<Arg2> &,const boost::lambda::lambda_functor<Arg3>
&)' : could no
t deduce template argument for 'const boost::lambda::lambda_functor<T2> &' from
'std::basic_ostream<_Elem,_Traits>'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
D:\C++\Boost\Current\boost\lambda\if.hpp(100) : see declaration of
'boost::lambda::if_then_else'
fs.cpp(39) : error C2784: 'const
boost::lambda::lambda_functor>>
boost::lambda::if_then_else
(const boost::lambda::lambda_functor<Arg1> &,const
boost::lambda::lambda_functor<Arg2> &,const boost::lambda::lambda_functor<Arg3>
&)' : could no
t deduce template argument for 'const boost::lambda::lambda_functor<T2> &' from
'std::basic_ostream<_Elem,_Traits>'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
D:\C++\Boost\Current\boost\lambda\if.hpp(100) : see declaration of
'boost::lambda::if_then_else'