mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-10-23 10:28:11 +08:00
- Array index can be passed as int to operator[], allowing use of literal:
Json::Value array; array.append( 1234 ); int value = array[0].asInt(); // did not compile previously
This commit is contained in:
@@ -975,6 +975,14 @@ Value::operator[]( ArrayIndex index )
|
||||
}
|
||||
|
||||
|
||||
Value &
|
||||
Value::operator[]( int index )
|
||||
{
|
||||
JSON_ASSERT( index >= 0 );
|
||||
return (*this)[ ArrayIndex(index) ];
|
||||
}
|
||||
|
||||
|
||||
const Value &
|
||||
Value::operator[]( ArrayIndex index ) const
|
||||
{
|
||||
@@ -994,6 +1002,14 @@ Value::operator[]( ArrayIndex index ) const
|
||||
}
|
||||
|
||||
|
||||
const Value &
|
||||
Value::operator[]( int index ) const
|
||||
{
|
||||
JSON_ASSERT( index >= 0 );
|
||||
return (*this)[ ArrayIndex(index) ];
|
||||
}
|
||||
|
||||
|
||||
Value &
|
||||
Value::operator[]( const char *key )
|
||||
{
|
||||
|
Reference in New Issue
Block a user