
Beman Dawes <bdawes@acm.org> writes:
How should size( "foo" ) behave if "foo" is a directory? 1) Throw. The function should be renamed file_size().
[snip]
I'm inclined to go with (1), naming the function "file_size", and then add a function later to get the number of entries in a directory. But only if there is enough demand. I don't want to clutter up the library with a lot of seldom used functions that can be trivially written as user code.
I agree that (1) is the best option. Wanting to know the number of entries in a directory is less common, and can be written as: distance(directory_iterator(ph), directory_iterator()) The user may also wish to know the recursive size of all entries in the directory, but that is probably better handled by a more generic path visitor system. -- Jeremy Maitin-Shepard