On 3/8/06, Scott Meyers
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?
Try out: for_each(fs::directory_iterator(dir), fs::directory_iterator(), if_then_else(bind(&fs::is_directory, _1), cout << constant("D\n"), cout << constant("~D\n"))); The problem is that 'cout << "D\n"' is getting called immediately - as it's not a lambda expression, by making "D\n" a delayed constant it becomes one. This is documented at http://tinyurl.com/7jq3v. Hope that helps, Daniel