开发者

How to query the length of the boost::filesystem::path?

I couldn't find a 'path length' method in the boost::filesystem::path, is there one?

If there is no such method (why?) - should I 开发者_如何学Gouse .native().length() or .string().length() ?

I take it .string().length() should be faster, right?


.native() directly returns the internal representation of the path, while string() might perform some conversions. All in all, it won't make much difference though whether you use native().length() or string().length().


How about string() method? (returns std::string)

fs::path path;
...
path.string().size();


There is no length on path and it doesn't really follow why you would want it.

.string() is the generally recommended thing to use for externally visible representations. Check out the path decomposition table in their docs to get that warm fuzzy reassurance on what to expect.

I have no reason to believe performance would differ with either. You probably shouldn't worry about it until your profiler tells you to. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜