1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#include <string>
#include <map>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
using Notes = std::vector<unsigned>;
std::ostream& operator<<(std::ostream& os, const Notes& notes) {
std::copy(notes.begin(), notes.end(), std::ostream_iterator<int>(os, " "));
return os;
}
int main() {
const std::map<std::string, Notes> chords {{"min", {0, 3, 7}}, {"aug", {0, 4, 8}}, {"dim", {0, 3, 6}}};
bool fnd {};
for (const auto& [nam, note] : chords)
if (note == Notes {0, 4, 8}) {
std::cout << nam << '\n';
fnd = true;
break;
}
if (!fnd)
std::cout << "Not found\n";
if (const auto itr {chords.find("dim")}; itr != chords.end())
std::cout << itr->second << '\n';
else
std::cout << "Not found\n";
}
|