D
Dan Trowbridge
Hi everyone,
In my attempt to port code from VS 6.0 to VS.NET I had some code break along
the way, mostly due to not adhereing closely to the C++ standard. This may
be another instance but I can't think of a good fix, or even why it broke.
The problem
In one of my CFormView derived classes I have a member variable of the
type...
std::map<geom_base *, mass_props> mass_prop_map;
which I populate like...
mass_prop_map.insert(pair<geom_base *, mass_props>(af, mass_props(volume,
mass, weight, surface_area)));
where "mass_props" is a class whose constructor is called during the
"insert" shown above.
and "af" is a pointer to a class object that is derived from "geom_base"
I use the map to populated controls on the view with data from only certain
geom_base derived objects (ones that meet certain critera)
The .NET compiler doesn't like the std::map<geom_base *, mass_props>
mass_prop_map; variable declaration - it wouldn't compile.
If I change "geom_base *" to "geom_base" (and change the insert to reflect
the change) it will compile OK but in execution it will force a copy to be
made of the "af" object, which is quite huge and I don't need a local copy
inside the CFormView derived class, it would be a waste.
Am I breaking the rules again by using a pointer as a key type inside a
std::map? I don't see anything in the online-docs (MSDN) that says you
can't. Again, this worked fine inside VS 6.0.
Does anyone have any idea what is wrong and what is a work-around?
In the words of James Ingram: "I did my best but I guess my best wasn't
goooooood enough"
In my attempt to port code from VS 6.0 to VS.NET I had some code break along
the way, mostly due to not adhereing closely to the C++ standard. This may
be another instance but I can't think of a good fix, or even why it broke.
The problem
In one of my CFormView derived classes I have a member variable of the
type...
std::map<geom_base *, mass_props> mass_prop_map;
which I populate like...
mass_prop_map.insert(pair<geom_base *, mass_props>(af, mass_props(volume,
mass, weight, surface_area)));
where "mass_props" is a class whose constructor is called during the
"insert" shown above.
and "af" is a pointer to a class object that is derived from "geom_base"
I use the map to populated controls on the view with data from only certain
geom_base derived objects (ones that meet certain critera)
The .NET compiler doesn't like the std::map<geom_base *, mass_props>
mass_prop_map; variable declaration - it wouldn't compile.
If I change "geom_base *" to "geom_base" (and change the insert to reflect
the change) it will compile OK but in execution it will force a copy to be
made of the "af" object, which is quite huge and I don't need a local copy
inside the CFormView derived class, it would be a waste.
Am I breaking the rules again by using a pointer as a key type inside a
std::map? I don't see anything in the online-docs (MSDN) that says you
can't. Again, this worked fine inside VS 6.0.
Does anyone have any idea what is wrong and what is a work-around?
In the words of James Ingram: "I did my best but I guess my best wasn't
goooooood enough"