Can a variable Databe used as a map key?
Data
struct Data { Data(int X, int Y) {x=X; y=Y;} int x; int y; } int main() { std::map<Data, int> map_; map_.insert(std::make_pair(Data(1,2), 0)); //error inserting }
Yes, but you need to define operator<for the class type or use a custom comparison function for std::map.
operator<
std::map
An example of using a custom comparison function in the STL documentation.
if you don't need the <operator, you can use boost :: unordered_map.
Source: https://habr.com/ru/post/1751408/More articles:How to get the size of unlimited size of the form? - settingsSQL: How to make a selection by category? - sqlHow to identify code sections executed by multiple threads - javaКак сжать строку в .net С# и распаковать ее во флэш-памяти as3? - stringunlimited (or very high) integer - integerhow to do implicit type conversion used in my interpreter - typesКак получить дочерние элементы с композитным контролем во время разработки - asp.netdjango: Nonelogout in admins - pythonhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1751412/combine-multiple-fields-to-one-value-for-form-submission&usg=ALkJrhirO_W2EoNML7lPh6PNFDjaZ8gF-AJQuery: Can I have 2 tabs on one page? - jqueryAll Articles