- 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:
Baptiste Lepilleur
2010-12-24 12:47:14 +00:00
parent e6046e589e
commit fa130ef871
6 changed files with 56 additions and 3 deletions

View File

@@ -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 )
{