To which extent is "boost does it" equivalent to "very portable, use it"?
In this answer to a question asking "is doing Z this way portable" the idea is "boost does it this way, it means it is very portable".
Can I just always consult boost sources to find the most portable way of doing something in C++? How can I judge for myself if boost is reall开发者_开发技巧y such a collection of super-portable code?
There are some cases where Boost libraries exist precisely because they wrap very non-portable code. The most obvious examples are the file system and threading stuff.
The telltale sign of this is a large use of Boost.Config macros. Boost code that doesn't depend on Boost.Config (or other non-standard #ifdefs) will be highly portable.
Boost is prety well tested against a variety of operating systems
Check out this page
Boost comes with some guidelines on how to program for portability; libraries are throroughly peer reviewed before acceptance -- although compiler support can be dropped for particular libraries if there is no reasonable way of implementing the libraries Raison d'être, and the library brings break-through concepts -- e.g., boost::mpl didn't work well on sun compilers for a long time.
So, yes you can just consult the sources of libraries -- however, expect a major headache, portable coding requires levels upon levels of indirection.
精彩评论