Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-21216

GenericMap converts C-strings to bool

    Details

    • Type: Bug
    • Status: To Do
    • Resolution: Unresolved
    • Fix Version/s: None
    • Component/s: afw
    • Labels:

      Description

      Calling MutableGenericMap::insert(K, T) with a C-style string literal as the value causes an insertion of a value of type const char*, which gets converted to bool. This confusing behavior is not changed by reordering the definition of GenericMap::StorableType so that std::string comes before bool.

      The issue can be worked around by using C++11 string literals, or by using a strongly typed key.

      Find if there's a way to cause C-strings to get converted to std::string in GenericMap. There may not be, as the conversion seems to be driven by C++ overload resolution rules.

        Attachments

          Issue Links

            Activity

            Hide
            krzys Krzysztof Findeisen added a comment - - edited

            I think this one can be solved with an Obvious Rules Patch: provide a (non-template?) overload that takes K and const char*, and have it delegate to the string template. We can solve a related issue with makeKey in the same way.

            Show
            krzys Krzysztof Findeisen added a comment - - edited I think this one can be solved with an Obvious Rules Patch: provide a (non-template?) overload that takes K and const char* , and have it delegate to the string template. We can solve a related issue with makeKey in the same way.

              People

              • Assignee:
                krzys Krzysztof Findeisen
                Reporter:
                krzys Krzysztof Findeisen
                Watchers:
                Krzysztof Findeisen
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: