I have a problem with understanding of std::bitset. I want to use bitset as a switch for mutliple functions.
Imagine class A and function Func1. Constructor looks like this A(bool procFunc). Usage is simple. If I want to use Func1 i will pass true, otherwise false. Easy. I have a multiple choices and one bool is not enough so i want to use std::bitset.
Very very simple draft:
class A {
public:
A(); // default ctor
A(bool procFunc); // parameterized ctor with bool
A(std::bitset<N>& bs); // parameterized ctor with bitset
private:
bool _procFunc;
std::bitset<4> _bs;
void Func1();
void Func2();
void Func3();
void Func4();
};
A:A() {}
A:A(bool procFunc) :
_procFunc(procFunc)
{}
A:A(std::bitset<N>& bs) :
_bs(bs)
{}
If I had only Func1. I would switch on this way:
if(_procFunc == true){
Func1();
}
But I dont know how to exactly use std::bitset for multiple choices. I want to define some enum or sth similar and define 0001 calls Func1() ... 0010 calls Func2() ... 0100 calls Func2() ... 1000 calls Func4().
Thanks for any help.