Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-12-17 12:59:11

Beman Dawes <bdawes_at_[hidden]> writes:

> At 06:23 AM 12/17/2003, Bronek Kozicki wrote:
> >I have two errors while building boost on MSVC71 (toolset vc7.1).
> >Apparently boost::filesystem::directory_iterator should have member
> >functions "decrement" and "advance", but these functions do not exist,
> >at least on my platform.
> It is more complicated than
> that. boost::filesystem::directory_iterator is an input iterator. It
> is specified like this:
> class BOOST_FILESYSTEM_DECL directory_iterator
> : public boost::iterator_facade<
> directory_iterator,
> path,
> boost::single_pass_traversal_tag >
> Perhaps I've got that wrong, but it has worked since the new-style
> iterator_facade was introduced, and it still compiles fine and passes
> all tests when built as a static library. See today's regression
> tests.
> The problem arises only when it is built as a Windows DLL.
> I could use some help on this. I don't understand why building as a
> DLL causes boost::iterator_facade to instantiate differently. Is the
> BOOST_FILESYSTEM_DECL the problem, and if so, what is the fix?

IIUC Exporting a class template in a DLL instantiates all of its
non-template member functions, so yes, that's the problem.

There are a few possible fixes:

  1. stop exporting it; make everything inline (you can dispatch to
     exported implementation functions).

  2. provide dummy advance and decrement functions

I'm sure there are a few others, but those are the ones that are
obvious to me. I prefer #1 because it prevents misuse from compiling.

Dave Abrahams
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at