I have three files:
- domain.h defines some plain structs. one of the fields is a boost::optional
- convert.h defines template specialization that convert the plain structs to some other type.
- lib.cpp that uses domain.h and converts.h
So, the includes are:
//domain.h
#include <boost/optional>
//convert.h
#include "domain.h"
#include <boost/optional>
//lib.cpp --- version 1 does not work
#include "domain.h"
#include "convert.h"
The compiler(VS2010) gave a uninformative error message. I tried adding the boost optional include:
//lib.cpp --- version 2 works
#include <boost/optional>
#include "domain.h"
#include "convert.h"
How come the boost/optional header include wasn't carried over from domain.h and/or convert.h to lib.cpp?
EDIT:
The compiler complained it could find a template specialization for boost::optional.
I found a problem. there's another file which defines the conversion specialization for boost::optional, convert-boost-optional.h
If I change convert.h to
#include "domain.h"
#include <convert-boost-optional.h>
then version 1 works too. What puzzles me is how come version 2 compiles without including convert-boost-optional.h anywhere?
EDIT:
I got myself confused. I actually included <convert-boost-optional.h>
in lib.cpp in version 2. Everything makes sense now. Sorry!