Компилятор пишет, что не найдена функция transform с нужной сигнатурой. Один или несколько параметров не тех типов, которые ей нужны.
Надо найти, как она объявлена (вкл. все перегрузки), и сравнить типы параметров.
Кроме того, если меня не подводит мой старческий маразм, то toupper всю дорогу было не функцией, а макросом, раскрывающимся в лукап свойств символа по массиву (так быстрее). Поэтому в функцию его передать нельзя. С этим в разных реализациях сей боролись по-разному: какие-то среды предлагали параллельную реализацию toupper в виде функции (_toupper или как-то так), другие молча забивали на проблему. В крайнем случае можно объявить свою функцию и вызвать в ней toupper, и свою передавать.
#include <algorithm>
#include <iostream>
#include <string>
#include <fstream>
#include <tuple>
using namespace std;
class Lamp {
public:
Lamp(const string& color) : status(false), color(color) {}
void blink() {
if (color != "black") {
transform(color.begin(), color.end(), color.begin(), toupper);
}
status = true;
}
void constantly() {
transform(color.begin(), color.end(), color.begin(), tolower);
}
void on() {
status = true;
}
void off() {
status = false;
}
string get()const {
return status? color : black;
}
private:
bool status;
string color;
inline static const string black = "black";
};
class Lights {
public:
static const auto limit = 5;
Lights() : phase(0), red("red"), yellow("yellow"), green("green") {}
pair<tuple<string, string, string>, int> status(const int step) {
green.constantly();
yellow.constantly();
red.constantly();
switch (step % limit + 1) {
case 0:
red.off();
yellow.off();
green.on();
phase = 0;
break;
case 1:
red.off();
yellow.off();
green.blink();
phase = 1;
break;
case 2:
red.off();
yellow.on();
green.off();
phase = 2;
break;
case 3:
green.off();
yellow.off();
red.on();
phase = 3;
break;
case 4:
red.on();
yellow.on();
green.off();
phase = 4;
break;
case 5:
red.off();
yellow.blink();
green.off();
phase = 5;
break;
}
return make_pair(make_tuple(red.get(), yellow.get(), green.get()), phase);
}
pair<bool, int> good(const tuple<string, string, string>& box) {
for (int n = 0; n <= 5; ++n) {
if (status(n).first == box) return make_pair(true, status(n).second);
}
return make_pair(false, -1);
}
private:
int phase;
Lamp red;
Lamp yellow;
Lamp green;
};
int main() {
ifstream inp("INPUT.TXT");
string green, yellow, red;
inp >> red >> yellow >> green;
tuple<string, string, string> box{ red, yellow, green };
ofstream out("OUTPUT.TXT");
Lights lights;
auto [ok, phase] = lights.good(box);
if (ok) {
if (phase != Lights::limit) ++phase;
auto [status, step] = lights.status(phase);
auto& [r, y, g] = status;
out << r << '\n' << y << '\n' << g << '\n';
} else {
out << "error";
}
inp.is_open() ? inp.close() : void();
out.is_open() ? out.close() : void();
}