File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed
Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -169,6 +169,8 @@ class Value {
169169 MapProxy operator [](const std::string&);
170170 const Value operator [](const char *) const ;
171171 MapProxy operator [](const char *);
172+ const Value operator [](char *) const ;
173+ MapProxy operator [](char *);
172174 const Value& operator [](int ) const ;
173175 Value& operator [](int );
174176
Original file line number Diff line number Diff line change @@ -390,6 +390,16 @@ MapProxy Value::operator[](const char *input) {
390390}
391391
392392
393+ const Value Value::operator [](char *input) const {
394+ return operator [](std::string (input));
395+ }
396+
397+
398+ MapProxy Value::operator [](char *input) {
399+ return operator [](std::string (input));
400+ }
401+
402+
393403const Value& Value::operator [](int index) const {
394404 switch (prv->type )
395405 {
Original file line number Diff line number Diff line change @@ -509,6 +509,16 @@ void test_value() {
509509 assert (itConst == valConst.end ());
510510 }
511511
512+ {
513+ Hjson::Value val;
514+ val[" first" ] = " leaf1" ;
515+ char szKey[20 ];
516+ sprintf (szKey, " first" );
517+ assert (val[szKey] == " leaf1" );
518+ char *szKey2 = szKey;
519+ assert (val[szKey2] == " leaf1" );
520+ }
521+
512522 {
513523 Hjson::Value val;
514524
You can’t perform that action at this time.
0 commit comments