mardi 28 juillet 2015

can't access const static std::map enum struct

I am trying to have a enum struct mapping to guarante a default value to a config value if it does not exsist and to guarante only access to "real" config values.(No std::string get)

So the Header looks like this:

enum ConfigValues
{
    LOG_LEVEL,
};

class Config
{
public:
    std::string get(const ConfigValues& key);
private:
    struct ConfigMapping
    {
        std::string configKeyString;
        std::string defaultValue;
    };

    const static std::map<ConfigValues, ConfigMapping> m_mapping;
}

And the cpp contains this:

const std::map<ConfigValues, Config::ConfigMapping> Config::m_mapping=
{
    {LOG_LEVEL, { "logLevel", "5" } },
};
std::string Config::get(const ConfigValues& key)
{
    std::string key = m_mapping[key].configKeyString; // <-- Does not work
}

But i cant access the map.

Aucun commentaire:

Enregistrer un commentaire