Re: [boost] [system] Why is this not header-only?

Message: 11 Date: Tue, 3 Apr 2007 22:23:19 -0400 From: Jody Hagins <jody-boost-011304@atdesk.com> Subject: Re: [boost] [system] Why is this not header-only? To: boost@lists.boost.org Message-ID: <20070403222319.6745f5c9.jody-boost-011304@atdesk.com> Content-Type: text/plain; charset=US-ASCII
On Wed, 4 Apr 2007 00:43:22 +0000 (UTC) Steven Watanabe <steven@providere-consulting.com> wrote:
There's always explicit instantiation.
Right. However, that's not free either. In fact, it adds significant developer overhead to get all the explicit instantiations right.
Note, I understand the "library implemented in a header" for templates. I still think there's ways to put parts of them in libraries, especially when providing wrappers around system resources.
For system resources, I find the inline pimpl idiom is quite useful: First, design the class as a pimpl. You then create an ipp file and selectively #include it in the header file, with the pimpl definition. The ipp file also contains all of the includes needed for the pimpl definition. The only trick is that the "inline" keyword needs to be selectively prefaced to the class's member function definitions to make linking work correctly. That can be done with a macro. You get the best of both worlds. When in debug mode, with static libraries pre-built, the libraries have practically no compile-time performance. Flick a #define on in release mode, for example, and you get maximum inlining and slow compiles. This technique doesn't work for very simple data types since it still incurs the pimpl's dynamic memory allocation overhead on construction. Jody -- re: boost build, I'd recommend checking out their specific mailing list. It's hard to get started, and error messages are frequently very misleading, but it's the best C++ build tool I've seen yet. Regards, Matthew Herrmann
participants (1)
-
Matthew Herrmann