commit | 89e50181e986346d8f62f978e680a29d901c8fd2 | [log] [tgz] |
---|---|---|
author | Josh Gao <jmgao@google.com> | Mon Mar 09 12:05:32 2020 -0700 |
committer | Josh Gao <jmgao@google.com> | Mon Mar 09 12:32:56 2020 -0700 |
tree | 40315515cd4fcf9475e3a0ab883a350625d9742e | |
parent | b3df599c20a761c71a8b797b7218e2ba6a295d25 [diff] |
base: tag unique_fd::reset as reinitializing for clang-tidy. Appease clang-tidy by marking reset() as a method that reinitializes after moving out of a unique_fd. Unfortunately, there isn't an attribute that let us mark the type as being safe to use after move in general, which means that moving out of a unique_fd and then calling get() on it will still be frowned upon. clang-tidy has a hard-coded list of standard container types that are safe to use after move, but doesn't provide a way to mark custom types as satisfying this condition. Bug: http://b/150959261 Test: reverted the change to unique_fd.h and the test failed Change-Id: Ide73d7caa4cd2b192018f111059d696dca4de987
This library is a collection of convenience functions to make common tasks easier and less error-prone.
In this context, "error-prone" covers both "hard to do correctly" and "hard to do with good performance", but as a general purpose library, libbase's primary focus is on making it easier to do things easily and correctly when a compromise has to be made between "simplest API" on the one hand and "fastest implementation" on the other. Though obviously the ideal is to have both.
The intention is to cover the 80% use cases, not be all things to all users.
If you have a routine that's really useful in your project, congratulations. But that doesn't mean it should be here rather than just in your project.
The question for libbase is "should everyone be doing this?"/"does this make everyone's code cleaner/safer?". Historically we've considered the bar for inclusion to be "are there at least three unrelated projects that would be cleaned up by doing so".
If your routine is actually something from a future C++ standard (that isn't yet in libc++), or it's widely used in another library, that helps show that there's precedent. Being able to say "so-and-so has used this API for n years" is a good way to reduce concerns about API choices.
Unlike most Android code, code in libbase has to build for Mac and Windows too.
Code here is also expected to have good test coverage.
By its nature, it's difficult to change libbase API. It's often best to start using your routine just in your project, and let it "graduate" after you're certain that the API is solid.