You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I hope you are well and good amidst the current pandemic.
I've been hitting a minor snag when trying to store mx::api types in various const/global containers. It would be nice if PitchData offered a flexible value constructor to remedy this.
For example: PitchData(Step step = Step::c, int alter = 0, double cents = 0.0, Accidental c = Accidental::none, bool = false, bool = false, bool = false, bool = false, int octave = 4);
This would enable a user to create pitches like this: PitchData p{Step::c, -1}; which is nice.
A real world use case, I am building an unordered_map to map a root to a mx::api::KeyData fifth.
namespacemx {
usingnamespaceapi;
}
namespacestd {
template <>
structhash<mx::PitchData> {
constexprinlinesize_toperator()(const mx::PitchData& p) const {
size_t h1 = size_t(p.step) << 32;
size_t h2 = size_t(p.alter);
return h1 ^ h2;
}
};
} // namespace stdnamespace {
std::unordered_map<mx::PitchData, int> root_to_key_circle {
{ mx::PitchData{/* you cannot do that :( */ }, -1 },
{ mx::PitchData{/* you cannot do that :( */ }, 0 },
{ mx::PitchData{/* you cannot do that :( */ }, 1 },
// etc
};
} // namespace
Now, you may want to have different or other types of constructors, but the general idea is the same. It would be nice to be able to construct a PitchData with a few arguments.
Take care and stay safe!
The text was updated successfully, but these errors were encountered:
Hi, I hope you are well and good amidst the current pandemic.
I've been hitting a minor snag when trying to store
mx::api
types in various const/global containers. It would be nice ifPitchData
offered a flexible value constructor to remedy this.For example:
PitchData(Step step = Step::c, int alter = 0, double cents = 0.0, Accidental c = Accidental::none, bool = false, bool = false, bool = false, bool = false, int octave = 4);
This would enable a user to create pitches like this:
PitchData p{Step::c, -1};
which is nice.A real world use case, I am building an
unordered_map
to map a root to amx::api::KeyData
fifth.Now, you may want to have different or other types of constructors, but the general idea is the same. It would be nice to be able to construct a
PitchData
with a few arguments.Take care and stay safe!
The text was updated successfully, but these errors were encountered: