views:

152

answers:

3

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 really such a collection of super-portable code?

+3  A: 

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.

Hassan Syed
@Hassan: Just to know - was `mpl` now working well because of the compiler not following the standard thoroughly or was the code not written strictly adhering to C++03? Reason am curious is, I couldn't comprehend why a code wouldn't run right when it's following the standard and the same doubt with compilers too.
legends2k
I don't know the precise details, although it does work on recent compilers.
Hassan Syed
Hmm. Those guidelines don't require that the code will work on all conforming compilers, and don't require that the code work on any non-conforming compiler. That's not quite what is normally meant when people say, "is this code portable?", although I see the pragmatism of Boost's approach - accept an implementation of experimental libraries if it promises portability, and work out how to actually port it later. In practice, stable Boost code is much "better" than those guidelines specify.
Steve Jessop
+4  A: 

Boost is prety well tested against a variety of operating systems

Check out this page

f4
It's good, thanks for the link. Although, I should mention that only desktop/server platforms are tested/listed there. I've used `boost::shared_ptr` in *Windows Mobile* which ran flawlessly. Since it's all written in the header, I didn't even compile boost. So a test covering a large spectrum should help better.
legends2k
+2  A: 

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.

MSalters