gpt4 book ai didi

C++ 映射 STL 错误 : size of array 'apn2policy' has non-integral type 'const char [13]'

转载 作者:太空宇宙 更新时间:2023-11-04 16:11:44 25 4
gpt4 key购买 nike

我有以下类型定义

struct PolicyRuleInfo{
BearerQoSInfo stBearerQoS;
TFTInfo stTFTInfo;

PolicyRuleInfo(){};
PolicyRuleInfo( BearerQoSInfo const& qos, TFTInfo const& tft)
: stBearerQoS(qos), stTFTInfo(tft)
{ }
};

typedef map<string, PolicyRuleInfo> listOfPolicyRuleInfo;

struct IPAddressPolicyRulesInfo{
CIPAddress ipAddress;
listOfPolicyRuleInfo policyRules;
IPAddressPolicyRulesInfo(){};
IPAddressPolicyRulesInfo(CIPAddress ipaddr, string policyRuleName, PolicyRuleInfo policyRule): ipAddress(ipaddr){policyRules[policyRuleName]=policyRule;};

void addPolicycyRule(string policyRuleName, PolicyRuleInfo policyRule) { policyRules[policyRuleName]=policyRule; }
};

typedef map<string, IPAddressPolicyRulesInfo> APN2PolicyRules;

typedef map<string, APN2PolicyRules> IMSI2APNPolicyRules;

稍后在 cpp 中:

u32 CPCRF::m_pNumPCCRulesViaCLI = 0;

listOfPolicyRuleInfo CPCRF::m_mlistOfCliConfiguredPolicyRules;

// map IMSI to PolicyRules
IMSI2APNPolicyRules CPCRF::m_mIMSI2PCRFInfo;

// Assign some default Policies (Applicable to all subscribers) , can be changed via CLI
listOfPolicyRuleInfo m_mlistOfCliConfiguredPolicyRules = boost::assign::map_list_of("PolicyRule_Internet", PolicyRuleInfo( BearerQoSInfo(9), TFTInfo()))
("PolicyRule_Voice_C", PolicyRuleInfo( BearerQoSInfo(5), TFTInfo()))
("PolicyRule_Voice_U", PolicyRuleInfo( BearerQoSInfo(1), TFTInfo()));

listOfPolicyRuleInfo::iterator it = m_mlistOfCliConfiguredPolicyRules.find("PolicyRule_Internet");

if (it != m_mlistOfCliConfiguredPolicyRules.end() )
{
IMSI2APNPolicyRules::iterator itr= m_mIMSI2PCRFInfo.find(imsi);

if (itr == m_mIMSI2PCRFInfo.end() )
{
IPAddressPolicyRulesInfo ipAddrPolicyRules(ueIPAddress, "PolicyRule_Internet", it->second);

APN2PolicyRules apn2policy["Apn_Internet"]=ipAddrPolicyRules;

m_mIMSI2PCRFInfo[imsi] = apn2policy;

我收到错误消息说数组“apn2policy”的大小具有非整数类型“const char [13]”

早些时候,我将 listOfPolicyRuleInfo 声明为 typedef 列表,但是当更改为映射时,出现此错误。

谢谢,开发包

最佳答案

APN2PolicyRules apn2policy["Apn_Internet"]=ipAddrPolicyRules;

此行试图声明一个 APN2PolicyRules 数组,但 size 参数是一个没有任何意义的字符串文字。

您最有可能想做的是:

APN2PolicyRules apn2policy; // create map
apn2policy["Apn_Internet"]=ipAddrPolicyRules; // set rule

关于C++ 映射 STL 错误 : size of array 'apn2policy' has non-integral type 'const char [13]' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27890632/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com