Boost Bimap Question

Hello,
I've started using boost bimap recently and i encountered a problem.
With the standard c++ containers, I can always use forward declaration of my
classes in the interface files (header files) and then include the
appropriate header files in the implementation files (source files).
With boost bimap this seems to be not possible. Lets say I've MyClass and I
do like this.
----------------------------
class MyClass
boost::bimap

Surya Kiran Gullapalli wrote:
With the standard c++ containers, I can always use forward declaration of my classes in the interface files (header files) and then include the appropriate header files in the implementation files (source files).
With boost bimap this seems to be not possible. Lets say I've MyClass and I do like this.
---------------------------- class MyClass
boost::bimap
my_bimap ; -------------------------- The compiler spits out a lot of error messages. But If i avoid forward declaration and include MyClass header file before declaring boost::bimap, every thing is normal.
First of all, your MyClass forward declaration should end with a
semicolon (;), of course! Still, you're saying that the forward
declaration would be sufficient when you declare an instance of a
container from the Standard C++ Library, right? So would the following
compile on your platform?
//----------------------------
#include <map>
#include <string>
using std::string ;
class MyClass ;
std::map

AMDG Niels Dekker - mail address until 2008-12-31 wrote:
First of all, your MyClass forward declaration should end with a semicolon (;), of course! Still, you're saying that the forward declaration would be sufficient when you declare an instance of a container from the Standard C++ Library, right? So would the following compile on your platform?
//---------------------------- #include <map> #include <string> using std::string ;
class MyClass ; std::map
my_map ; int main() { return 0 ; } //----------------------------
It doesn't compile on my platform. I also tried www.dinkumware.com/exam and www.comeaucomputing.com/tryitout
That can't possible compile. It is possible that
#include <map>
#include <string>
using std::string ;
class MyClass ;
extern std::map

Okay,
I should have been more clearer in my question.
Lets say I've these files.
global.hpp
main.cpp
someother.cpp
myclass.hpp.
global.hpp has a member variable declared like this. (my global.hpp has
static members and static variables every where and nothing else)
static map

AMDG Surya Kiran Gullapalli wrote:
Okay, I should have been more clearer in my question.
Lets say I've these files.
global.hpp main.cpp someother.cpp myclass.hpp.
global.hpp has a member variable declared like this. (my global.hpp has static members and static variables every where and nothing else)
static map
myMap ;
This is inside a class, right?
Now my main function includes global.hpp, but is not dependent on myclass. If i include myclass.hpp in global.hpp, I'd end up compiling main.cpp when ever myclass.hpp is changed. To avoid this, I forward declare myclass in global.hpp (with out including myclass.hpp)
global.hpp should have a cpp file? Why don't you hide myMap inside that file. myMap cannot be used without including myclass.hpp, so if main.cpp does not need myclass, it would be better to split up globals.hpp into separate files.
my someother.cpp includes global.hpp and is dependent on myclass as well, so includes myclass.hpp as well.
So what i'm asking is just forward declaring myclass in global.hpp will not cause any problem for me, when I'm working with standard containers like map, set etc. But that is not the case for bimap.
I don't think that you should rely on this behavior for standard containers, either. In Christ, Steven Watanabe
participants (3)
-
Niels Dekker - mail address until 2008-12-31
-
Steven Watanabe
-
Surya Kiran Gullapalli