This repository has been archived on 2022-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
turing/utils/operators.cpp

26 lines
790 B
C++
Raw Permalink Normal View History

2022-11-26 05:03:22 +01:00
#include <cstdlib>
#include "../turing.cpp"
/**
* @brief Replaces provided string with appriopriate Turing::Instruction<char, char>
* it takes 'l' character as a left move
*/
constexpr Turing::Instruction<char, char> operator ""_i (const char* txt, const size_t len) {
char cS = *txt++;
char cV = *txt++;
char nS = *txt++;
char nV = *txt++;
Turing::Movement mv = *txt++ == 'l' ? Turing::Movement::left : Turing::Movement::right;
return Turing::Instruction<char, char>(cS, cV, nS, nV, mv);
};
// Replaces provided string with aprriopriate vector<char>
const std::vector<char> operator ""_v (const char* txt, const size_t len) {
auto rvalue = std::vector<char>(len);
for (int i = 0; i < len; i++) {
rvalue[i] = *txt++;
}
return rvalue;
}