Код: Выделить всё
typedef std::tuple sequence_t;
int sequence_id(int a, int b) {
sequence_t key = {a, b, -1, -1};
if (!this->m_sequence_id.contains(key)) {
return -1;
}
return this->m_sequence_id[key];
}
int sequence_id(int a, int b, int c) {
sequence_t key = {a, b, c, -1};
if (!this->m_sequence_id.contains(key)) {
return -1;
}
return this->m_sequence_id[key];
}
int sequence_id(int a, int b, int c, int d) {
sequence_t key = {a, b, c, d};
if (!this->m_sequence_id.contains(key)) {
return -1;
}
return this->m_sequence_id[key];
}
Я пробовал много разных вещей и даже взял книгу о шаблонах. , но мне не удалось заставить мой код правильно заполнить кортеж. Он не компилировался (в большинстве случаев потому, что индекс, к которому я вызывал std::get, был переменной).
Есть ли простой способ сделать это?
Подробнее здесь: https://stackoverflow.com/questions/786 ... -arguments