|
Boost Users : |
From: Hicham Mouline (hicham_at_[hidden])
Date: 2007-12-12 15:13:39
Hello,
I am attempting to design a class:
class C {
std::map<double, const A> ma;
std::map<double, const B> ma;
.
public:
C(...);
};
The keys in the 2 maps are always identical. So I could choose:
std::map<double, const std::pair<A,B> >
or
std::map<double, const std::pair<A,B>* >
(ps: AFAIK, using a const-ref for the pair is impossible, but possible with
some boost classes)
Q1:
Is there a difference in memory usage, in access speed or in code
readability
between the top choice and bottom ones?
Q2:
Between the 2 bottom ones (storing the pair object in the map vs storing the
ptr)
Q3:
For users of class C, what sort of constructors should I offer?
C::C(const std::map<double, const std::pair<A,B>* >& )
Or, should I allow adding elements to the map after the object being
constructed?
C::add(double, const A&, const B&)
Are there better ways with boost classes?
Thank you for boost and your time,
Rds,
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net