
That's an implementation detail. It isn't required by the spec, although that may be the most obvious way to implement the spec. An alternate implementation would be to keep a pool of directory entry objects and recycle them if performance was a concern. It would be great if Boost had a cache library to make such a strategy trivial to implement.
What kind of cache did you have in mind? Regex has an "Object Cache" (see boost/regex/pending/object_cache.hpp) that I always meant to submit for full Boost status but never got around to :-( It simply maps a "key" to an instance of an object constructed from the key: if the object already exists it returns it, otherwise it constructs a new one and caches it. Objects are returned as a shared_ptr<const Object> (the shared_ptr is needed for memory management, since neither the cache not the client have exclusive ownership on the object). Useage is simply: shared_ptr<const Object> obj = object_cache<Key, Object>::get( my_key, max_number_of_objects_to_cache); To be honest usefulness is pretty limited, and threading issues add a small performance hurdle, that means that "Objects" have to be fairly expensive to construct before it becomes useful. Still, there you go ;-) John.