H
Hicham Mouline
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:air<A,B> >
or
std::map<double, const std:air<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, access speed or 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:air<A,B>* >& )
Or, should I allow adding elements to the map after the object being
constructed?
C::add(double, const A&, const B&)
Rds,
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:air<A,B> >
or
std::map<double, const std:air<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, access speed or 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:air<A,B>* >& )
Or, should I allow adding elements to the map after the object being
constructed?
C::add(double, const A&, const B&)
Rds,