On Tue, Mar 12, 2013 at 6:49 PM, Nat Linden
On Tue, Mar 12, 2013 at 12:43 AM,
wrote: On Tue, Mar 12, 2013 at 2:21 AM, Ion Gaztañaga
wrote: El 11/03/2013 13:20, lazylabs@gmail.com escribió:
However, I would prefer to do this with a std::string, which results in compilation errors:
persons->at(std::string("H")).print();
Is it possible to write the above statement, i.e. accessing the map allocated in shared memory with std::string?
No, as the key_type is not std::string. It's a bit ugly but to fix this has no easy fix.
As I understand, the reason why we cannot lookup ShmemString with std::string is because of the template argument, which I have given while creating the unordered_map:
std::equal_to<KeyType>,
Just guessing, if something can be done here?
It seems to me that within the last year or so another person on this mailing list (who had his own local idiosyncratic string type) was asking about passing std::string or const char* key arguments for map lookup. I don't even think it was specific to Interprocess. I believe he was proposing string comparators accepting range-of-characters rather than a specific string type.
Sorry for vagueness; I don't have time to search for it myself...
Sorry if I was vague, I was more interested in "why" this cannot be done. I already got a No (and that too from the library implementer himself. Thanks) and based on that I have already implemented a different solution in my code, to have integer lookups, rather than string-based lookups. Thanks.