Sep 5, 2011 at 8:43pm UTC
How can I write a template for boolean operators for bitsets?
I want to be able to do something like:
1 2
template <class itemtype>
bool operator < (bitset<itemtype> lhs, bitset<itemtype> rhs);
so that I won't have to write a seperate function for each size of bitset.
Thanks
Last edited on Sep 6, 2011 at 5:51pm UTC
Sep 6, 2011 at 6:00pm UTC
Does the code you posted not work or something?
personally I would pass by const reference:
1 2
template <class T>
bool operator < (const bitset<T>& lhs, const bitset<T>& rhs);
Last edited on Sep 6, 2011 at 6:00pm UTC
Sep 6, 2011 at 6:06pm UTC
No, not on codeblocks with mingw. I forget the error though (I'm on a different computer right now) but I think it may have something to do with the fact that the parameter for bitset takes a const int, like:bitset<4> B;
Sep 6, 2011 at 6:36pm UTC
No, just want to compare bitsets with the same size, but I will try that and see if it works.