I'd like to use the shift operators as doing a bit rotation instead of their actual bit shift. This is my expected behavior:
std::bitset<8> b8("1010"); // b8 = 00001010
b8 <<= 5; // b8 = 01000001
So I try and overloaded the <<=
operator, referencing the bitset
definition, as followed:
#include <iostream>
#include <bitset>
using namespace std;
template <size_t size>
bitset<size>& bitset<size>::operator<< (size_t pos) noexcept { // an error at here
}
I've got an error at keyword operator
:
Out-of-line definition of 'operator<<' does not match any declaration in 'bitset<_Size>'
How can I fix it? My env. is:
- Xcode : Version 9.1 (9B55)
- LLVM(
llvm-g++ -v
) : Apple LLVM version 9.0.0 (clang-900.0.38)