A
aaragon
Hi everyone, I am trying to create a class but I would like to be able
to chose between several data structures for one of its members. The
basic idea is
template
<
class ClassA
{
Sequence* storage_;
public:
// parameter constructor
ClassA(size_t l) {storage_ = new Sequence(l); }
// size
size_t size() { return storage_->size(); }
bool element(size_t site_) {
// since in the bitset the bits are stored from right to left, the
// actual complement of location site_ is located at a distance
// size() - 1 - site_ from the left
return (*storage_)[storage_->size() - 1 - site_];
}
void print() { cout<<*storage_; }
};
This works fine for the boost dynamic bitset that I've been working
with. However, if I try to use a std::vector instead of the
dynamic_bitset<> then the function element is no longer valid. Does
anyone know how can I fix this? I was thinking maybe in implementing a
wrapper along the data structure with but I need some help on this.
Thank you,
aa
to chose between several data structures for one of its members. The
basic idea is
template
<
class ClassA
{
Sequence* storage_;
public:
// parameter constructor
ClassA(size_t l) {storage_ = new Sequence(l); }
// size
size_t size() { return storage_->size(); }
bool element(size_t site_) {
// since in the bitset the bits are stored from right to left, the
// actual complement of location site_ is located at a distance
// size() - 1 - site_ from the left
return (*storage_)[storage_->size() - 1 - site_];
}
void print() { cout<<*storage_; }
};
This works fine for the boost dynamic bitset that I've been working
with. However, if I try to use a std::vector instead of the
dynamic_bitset<> then the function element is no longer valid. Does
anyone know how can I fix this? I was thinking maybe in implementing a
wrapper along the data structure with but I need some help on this.
Thank you,
aa